Sunday, October 28, 2012

As seen at PGConf.EU: call_graph

At the PostgreSQL Conference Europe 2012, Joel Jacobson was kind enough to present a project we've been working on: call_graph.  For those of you who weren't at the conference, call_graph is a PostgreSQL extension which tracks the stored procedure call stack during execution, gathering that data into a table.  That data can be analyzed or visualized in different ways; my attempt at visualizing it can be found under the utils/ subdirectory.  My apologies to anyone who's good with Perl.  I tried.

Unlike static analyzers, call_graph only looks at code paths that are actually executed, which results in both more accurate and more simple data.  Additionally, because there's no necessity to understand the actual code being executed, it works equally well regardless of the language you've chosen for your stored procedures.

The extension currently only works in PostgreSQL 9.1, but supporting 9.2 should be relatively simple.  If you want to use the utility scripts I've created to visualize the data, you will need Perl and GraphViz.

I can't recommend running the code in production, but if you do, let me know!  In any case, feel free to contact me with feature requests, bug reports (I think there's a way to report them on github, making them publicly available data) or anything else you can think of.