We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Seamless SQL optimization

Formal Metadata

Title
Seamless SQL optimization
Title of Series
Number of Parts
32
Author
Contributors
License
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
There are two types of analysis and optimization. The first, macro-analysis, is analyzing the workload as a whole. Usually, it is done using pg_stat_statements or pgBadger The second one is micro-analysis and the central tool here is the EXPLAIN command. And there is a huge gap between them, partially covered by auto_explain and pg_qualstats extensions. In this tutorial, we learn how to establish a smooth and seamless SQL optimization process in your organization? Topics we'll cover: What are the pros and cons of using pg_stat_statements compared to log analysis performed by pgBadger? What are the key metrics in macro-analysis and how to choose the most applicable in each case (is it total time consumed by an SQL query group? or average timing, or maybe shared buffers hit and read by the query group per second?); Closing the gap: how to switch from macro-analysis to micro-analysis (you identified a "bad" SQL group, how to start optimizing it and what is needed to make this process faster / more automated?). How to simplify the process of adaption of using EXPLAIN command by a wide range of backend developers, what metrics matter and how (timing vs buffers involved). EXPLAIN visualization technics and their pros and cons (PEV, and FlameGraphs for EXPLAIN). How to accumulate knowledge about SQL optimization, share it with teammates and improve collaboration.