Recursive CTEs: stop writing nested loops for trees
Hi there,
This week we go deeper into CTEs — the part your tooling politely ignores.
Recursive CTEs let you traverse trees and hierarchies cleanly, with one query, and without writing a tangle of loops.
→ Read now:
Recursive CTEs — Because writing nested loops for trees is psychopathic (and a little masochistic)
Why this matters
- Model org charts, categories, dependency trees without app-side loops
- Keep logic declarative and testable
- Works across major databases you already use
“Readable. Recursive. Realistic.”
This is Part 2 of the 3-part series on the SQL your ORM won’t tell you about.
📚 Previously on Efficient Laziness
- Part 1 — CTEs 101 (readable & maintainable SQL):
Your ORM is Lying to You About SQL (CTEs Explained) - Related — Choosing a vector database without the hype:
From Zero to 1-B Vectors: The 2025 No-BS Picking Guide
Next up: Part 3 Using CTEs When Your ORM Says No (The Lazy Developer's Survival Guide).
Efficient Laziness — Think once, well, and move forward.
Don't miss what's next. Subscribe to The Efficient Laziness Academy: