Visualizing data structures (e.g. in PostgreSQL)
When we think about the data structures our programs use or the execution flow of our programs, I’m pretty sure we all think visually and if we had to explain it to someone we would be drawing diagrams on a whiteboard. Yet pretty much all our coding and debugging is text-based. We are forced to visualize things in our minds.
I’ve been debugging the PostgreSQL codebase to better understand how things work. I think a lot of people treat it like a scary magical black box, but it’s quite easy to debug a query’s execution path, and start to understand how it works.
When we learn about databases, say from Andy Pavlo’s CMU database course, there are a bunch of core diagrams used to explain things. Like the parse tree, logical plan tree, physical plan tree, disk storage layout, btree/bitmap/hashmap index, etc.
So what I was thinking was to instrument the PostgreSQL C codebase (via LLVM-IR), and then visualize some of the key data structures and stores. Imagine how easy it would be to teach database internals, if you could type in a query, and then visually step through the actual execution of the query with visual diagrams. I would imagine that any PowerPoint slides and diagrams could be replaced by this visual interface with a slider and some filtering options for what to show.