Pev: Postgres ‘Explain’ Visualizer (2016)
tatiyants.com
tatiyants.com
https://dev.mysql.com/doc/workbench/en/images/wb-new-visual-...
The sample JSON of the plan doesn't indicate how big the boxes would be when presented on the UI. And also how to draw the connections between them.
Can I ask, do you use a library to handle laying out the visual network, or is that using custom JS?
https://www.eternum.io/ipfs/QmQ1Qh9moFgV4MikubnXzAmV3rD48JPG...
The one thing I wish it had is either the ability to not save plans automatically, or at least a button to clear the history. As it is, I just pull up a console from time to time and do localStorage.clear()
Unfortunately, flame graphs don't show (much) structure.
Now, as a second note, I do a lot of performance work (systems programming in stacks starting at hand-assembled machine code, working all the way up to scripting languages). Personally, I find flame graphs not as useful as a traditional (inverted-)back-trace. I think the structure encoded in a traditional (inverted-)back-trace tells you a lot about poorly designed algorithms and bad systems interactions in a way that flame graphs (mostly) erase.
Thanks
SQL query execution does not follow this structure. Query plans are executed in whatever order or degree of parallelism is appropriate. And linearising an SQL query plan is actually wrong. If you've ever watched SQL Server's Live Query Statistics play out, you'll know that the engine does whatever work it can when possible. It would be incorrect to think of the query execution as a stack the CPU can get stuck deep down in, and a flame graph would create an incorrect model.
As an exercise, where would you put self-time in a flame graph representation of an execution plan for a filtering node, or a sorting node? The engine doesn't report that, because filters happen inline (at least in batches) and sorts are optimised to happen progressively and can be scheduled in between IO handlers. Ask an expert about this, I'm not your guy.
Also, the data you want to see isn't represented by one dimension on the flame graph (how wide is this function call?), it is represented by many more: cost, CPU time, number of rows, IO operations, and estimations of all the above. The execution plan needs to be roomier, and include all this information, not merely wall clock time.
I'm sure these problems can be overcome, but it's a bit more complicated than I had imagined when I tried to do it myself. I also suspected nested-loop-joins on CTEs could further complicate the flame graph construction.
So if you just want to checkout the interface you can click to load up an example or two.
Hit "New Plan", and then in the top right there's a link that says "Create Sample Plan"
How feasible would it be to port this over to MySQL / MariaDB? I know EXPLAIN output on MySQL is much simpler than what you get out of Postgres so my gut feeling would be that it wouldn't be possible.
Edit: looks like MySQL can output it as JSON: https://dev.mysql.com/doc/refman/5.7/en/explain-output.html
[0] https://www.pgadmin.org/docs/pgadmin4/1.x/query_tool.html
C - https://github.com/lfittl/libpg_query
Ruby - https://github.com/lfittl/pg_query
Go - https://github.com/lfittl/pg_query_go
That said, the tool being discussed here (pev) is used to interpret EXPLAIN plans, which libpg_query doesn't give you, as its only concerned with the parsing stage, not the planning stage.
In order to plan a query you'll need more information from the actual database, including table statistics, config settings and the size of the underlying table :)
Never-before-on-the-HN-front-page tools for working with PostgreSQL queries seemed relevant to me; this info may help a few others.