The side quest that freed 10% of our database
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
incident.io engineer describes cutting one Postgres query from 33.8% of replica CPU time (280.7h over 3.5 days) to 0.3% (1.6h), about 175x less query time. A new btree index alone did not help, since the planner kept choosing an older GiST exclusion index. Rewriting the query as a row comparison, which GiST cannot serve, forced use of the new index. The figures come from the company's own pg_stat_statements exports for one query, compared across two windows.