Company
Date Published
Author
Tim Nolet
Word count
1498
Language
English
Hacker News points
None

Summary

The Checkly team recently optimized a Postgres query crucial to their dashboard, reducing response times from an average of ~100ms with peaks to a steady 1ms to 10ms. The optimization involved analyzing performance issues, testing fixes, and applying simple Postgres optimizations. A key finding was that two queries were consuming most of the execution time, one of which could be improved by using a composite index on `checkId` and `startedAt` fields in descending order. This solution resulted in a significant reduction in response times and p95 metric value, with Heroku metrics showing a drop from ~3 seconds to 175ms. The optimization was made possible by leveraging tools such as Heroku's pg:outliers command and Postgres' graphical interface for slowest execution time tab. The experience highlights the importance of finding the right angle, testing data, and confirming hypotheses in performance fixes.