可參考本文章:
https://dba.stackexchange.com/questions/245990/postgresql-extremely-slow-count-with-index-simple-query
vacuum analyze insider_event;
執行了 7 分鐘
ALTER TABLE insider_event SET (autovacuum_vacuum_scale_factor = 0, autovacuum_analyze_scale_factor = 0, autovacuum_vacuum_threshold = 10000, autovacuum_analyze_threshold = 10000);
跑了 1.2 分鐘
修改 work_mem:
https://www.pgmustard.com/blog/work-mem
記憶體調整
https://www.enterprisedb.com/postgres-tutorials/how-tune-postgresql-memory