Last updated on May 15, 2016
A friend of mine was recently discussing using Flame Graphs in a project of his, and it inspired me to see how I could abuse the format to present a visual model of SQL execution.
Originally I had thought of building my own interface, but apparently the author of the above site also maintains a great repo which allows you to skip some of the more difficult steps: https://github.com/brendangregg/FlameGraph.
There is a lot of detail there about profiling software with specific tools and how to convert their output to something the tool understands, but at its core the “folded” format is fairly easy to target and if you are fine with some text manipulation you can produce your own FGs and re-use the SVG generation, search, and zoom components of this tool.
What’s the format?
It doesnt take too much effort to suss out from flamegraph’s source:
# frame in the stack is semicolon separated, with a space and count at the end
# of the line.
Did you manage to make flame graphs for SQL server?
I did but I hated the results and found them not that useful.
I honestly don’t know why I never finished the post!
It took a day to write it up but in most SQL execution paths the procedure nesting wasn’t really that deep, 1-2 layers most of the time, and the depth and complexity would often come with nested views (at least in the problem I was trying to solve) so I threw it out.
SQL Server has a nest level you can exploit to understand this (either via the procedure or a trace) if you want to whip something up.