Query Optimization in Postgres with pg_stat_statements
"I want to work on optimizing all my queries all day long because it will definitely be worth the time and effort," is a statement that has hopefully never been said. So when it comes to query optimizing, how should you pick your battles? Luckily, in PostgreSQL we have a way to take a system-wide look at database queries:
- Which ones have taken up the most amount of time cumulatively to execute
- Which ones are run the most frequently
- And how long on average they take to execute
And that's just a few places you can shine a light on, using
pg_stat_statements
.
Source: Query Optimization in Postgres with pg_stat_statements, an article by Kat Batuigas.