Hi, I’m James

This is my blog. Enjoy.

View and reset PostgreSQL query statistics

Posted on

When trying to understand how to alleviate pressure from our PostgreSQL instances, we were using a query like this:

Which displays the 12 most expensive queries that postgres has spent time doing. It’s pretty useful for finding out where you should be putting indexes, or where you can change your application code to alleviate the pressure.

Once you’ve optimized all the things on the posts table and deployed out new code, you will want to get those statistics updated. I had a hard time figuring this one out, so I’m leaving it here for myself for later: