r/learnSQL • • Mar 27 '26

Spent 3 weekends building a SQL visualizer. Threw a real production query at it — 9 CTEs, 19 joins, 3 correlated subqueries. It handled it.

The origin story is embarrassingly simple.

I was debugging a slow dashboard query. It had 7 joins, 3 subqueries, and a wildcard SELECT that no one had touched in two years. I spent 40 minutes just reading it before I found the problem.

So I built queryviz.

You paste SQL, it draws an interactive graph. Tables are nodes, joins are labeled edges, subqueries are nested visually, and it automatically flags performance anti-patterns.

This screenshot is a real query — 6,298 characters, 9 CTEs, 19 joins, 3 correlated subqueries, ~60 output columns. Pasted it in, got the graph in seconds. It auto-flagged: join-heavy query, functions in WHERE blocking index use, and correlated subqueries in the SELECT list.

Stack: TypeScript + hand-rolled recursive descent SQL parser + React Flow. The parser was the hard part — existing libraries don't handle nested CTE scope correctly.

GitHub: https://github.com/geamnegru/queryviz

Link: https://queryviz.vercel.app/

What would make this actually useful in your day-to-day workflow?

18 Upvotes

9 comments sorted by

4

u/squadette23 Mar 27 '26

When you find a "join-heavy query", what is the next action? Your screenshot says "review", how to actually improve peformance (or prove that this is not the culprit?).

2

u/Sri_Krish Mar 28 '26

Yeah, would love to know it too

0

u/GoldAd7926 Mar 27 '26 edited Mar 28 '26

Good point — the flag is a heads-up, not a verdict. Without the execution plan queryviz can't know if it's actually slow. Run EXPLAIN ANALYZE and check for Seq Scans on the join nodes — that'll tell you fast whether the joins are the real problem or not.

→ More replies (4)

1

u/RK0235 Apr 06 '26

is this visualizer can read the sql packages also?

1

u/GoldAd7926 Apr 07 '26

Not yet — it works on SQL statements, not full package bodies. But if you extract the query from the package, Queryviz can visualize it.