Hubert Lubaczewski digs into a performance issue:
So, we have some databases on PostgreSQL 14 (yes, I know, we should upgrade, but it is LONG project to upgrade, so it’s not really on the table now).
Last week someone noticed problems with website. These were tracked to queries getting killed because of statement_timeout of 3 minutes.
The query was relatively simple (most of the identifiers were obfuscated, but tried to keep them somewhat memorable):
Click through for the story, analysis of the problem, and how creating a filtered index worked in this case. Filtered indexes are a beautiful thing when the optimizer knows how to make use of them.