Menu

Trying to make sense of query plans. Looking for opinions on how I draw them

#sql#redditsql#rows#estimate#gets
Reading 0:00
15s threshold

I've been trying to figure out the best way to make sense of a query, how it affects the database and whether there is room to improve it. I'm a visual person. If something has a diagram I understand it faster, and I wanted the same thing when I work with a database at work or on side projects. I want to see how the data is being retrieved or updated without working it out from the EXPLAIN text.

I've came up with following visual rule:

Each scan, join and sort is a bar. The band between two bars is as wide as the number of rows flowing through. Width is 1.2 + 0.55 x (log10 rows)² , capped between 1.5px and 34px. Linear made anything under 100,000 rows a hairline, and plain log made 1,000 and 1,000,000 look too close.

When the planner's estimate is off from the actual count by more than 2×, the band gets a dashed line showing the estimate. At 10x it gets a label.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.