'bundle exec rake db:migrate' يستغرق وقتًا طويلاً بسبب calendar migration

ystemd+  7660  0.0  0.3 352060 28284 ?        S    22:31   0:00 /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
systemd+  7667  0.0  0.1 352588  9628 ?        Ss   22:31   0:00 postgres: 13/main: checkpointer 
systemd+  7668  0.3  0.9 352060 78796 ?        Ss   22:31   0:03 postgres: 13/main: background writer 
systemd+  7669  0.0  0.1 352060 13696 ?        Ss   22:31   0:00 postgres: 13/main: walwriter 
systemd+  7670  0.0  0.1 352728 11892 ?        Ss   22:31   0:00 postgres: 13/main: autovacuum launcher 
systemd+  7671  0.0  0.0  67996  5320 ?        Ss   22:31   0:00 postgres: 13/main: stats collector 
systemd+  7672  0.0  0.0 352612  6640 ?        Ss   22:31   0:00 postgres: 13/main: logical replication launcher 
systemd+ 10900 82.0  3.8 487164 317728 ?       Rs   22:33  10:42 postgres: 13/main: discourse discourse [local] DELETE
systemd+ 10901  0.0  0.1 353432 13804 ?        Ss   22:33   0:00 postgres: 13/main: discourse discourse [local] idle

يُظهر htop أن مهمة discourse [local] delete هي التي تستهلك 100% من وحدة المعالجة المركزية. القطرة لديها 8 جيجابايت من ذاكرة الوصول العشوائي، وحاليًا أقل من 1 جيجابايت قيد الاستخدام (لا تشمل المخازن المؤقتة).

نظام التشغيل قديم، ولكن هذا يبدو غريبًا جدًا بالنسبة لي. هناك الكثير من ذاكرة الوصول العشوائي والقرص، ومهمة حذف postgres هذه قيد التشغيل منذ أكثر من 12 دقيقة. هناك أقل من 600 ألف منشور وأقل من 4 آلاف مستخدم، لذا فإن قاعدة البيانات ليست ضخمة. أوه. انتظر. دليل postgres_data هو 28 جيجابايت.

لقد قمت بتشغيل VACUUM VERBOSE ANALYZE;.

لقد فعلت هذا:

discourse=# SELECT checkpoints_timed, checkpoints_req FROM pg_stat_bgwriter; 
 checkpoints_timed | checkpoints_req 
-------------------+-----------------
                 6 |              20

أنا أحاول الآن إعادة الفهرسة بشكل متزامن. ربما سيساعد التفريغ وإعادة الفهرسة.