PostgreSQL 13 アップデート からの議論を続けます:
ふむ、それは少し多いように感じます。Meta には 33k 行あります。このクエリを見てみましょう:
select count(*), target, max(updated_at) from stylesheet_cache
group by target
order by target, max(updated_at)
ターゲットあたり 50 件のキャッシュされたスタイルシートという保持上限があるようですが、何らかの理由で target 指定子がリークしているようです?
| count | target | updated_at |
|---|---|---|
| 50 | discourse-adplugin_37 | 2021-04-23T19:08:43.292Z |
| 50 | discourse-adplugin_43 | 2021-04-23T19:08:52.227Z |
| 50 | discourse-adplugin_54 | 2021-04-23T19:09:01.121Z |
| 50 | discourse-adplugin_55 | 2021-04-23T19:09:10.245Z |
| 50 | discourse-adplugin_57 | 2021-04-23T19:08:25.265Z |
| 6 | discourse-adplugin_64 | 2021-01-01T11:49:49.071Z |
| 50 | discourse-adplugin_65 | 2020-09-21T16:23:50.647Z |
| 50 | discourse-adplugin_66 | 2021-04-23T19:08:34.562Z |
| 1 | discourse-adplugin_71 | 2020-01-15T21:07:26.560Z |
| 50 | discourse-adplugin_72 | 2020-04-01T23:52:51.691Z |
| 10 | discourse-adplugin_75 | 2020-08-18T20:17:16.954Z |
| 50 | discourse-adplugin_77 | 2020-09-21T18:22:22.334Z |
| 50 | discourse-adplugin_9 | 2021-04-23T19:09:19.228Z |
さらに、この行は明らかに誤っていますが、実際には問題ありません(単に不要な時期よりも早く削除処理を開始するだけです):
-count = StylesheetCache.count
+count = StylesheetCache.where(target: target).count
if count > MAX_TO_KEEP
... code that deletes old entries, sharded on target ...