Postgres FM cover image

Postgres FM

102 Query optimization

Oct 7, 2022
The podcast discusses query optimization in PostgreSQL, including steps involved, testing in a similar setup as production, analyzing the impact of sampling and bloat, optimizing queries' impact on other queries, and extreme indexing failure cases.
31:28

Podcast summary created with Snipd AI

Quick takeaways

  • To test optimization ideas effectively, it is crucial to replicate the production environment as closely as possible, including data, statistics, and query settings, and consider the impact on other queries and stability.
  • To holistically assess optimization changes, it is necessary to compare the performance before and after the change, monitor metrics like hot updates and index performance, estimate potential overhead, and use a combination of manual analysis, reactive approaches, and automated testing tools.

Deep dives

Verifying Optimization Ideas

To verify optimization ideas, it is important to test queries in a similar setup as the production environment. This involves ensuring the same data, statistics, and query settings are used. Achieving the same plan behavior on a non-production environment can be challenging, but there are specific tricks that can help, such as exporting and importing statistics or using tools like hypothetical indexes and partitions. It is crucial to ensure that the optimization ideas not only improve the targeted query but also do not negatively impact other queries or introduce instability.

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode