Discussion about this post

User's avatar
Neural Foundry's avatar

Excellent walkthrough of solving hiearchical data without the N+1 trap. The recursive CTE approach paired with Jakarta Data's @SQL annotation is really clever for keeping control over query semantics while still getting type-safe projections. One thing worth noting is how that zero-padded path column guarantees stable sorting even when sibling comment IDs are out of order. Would be interesting to benchmark how this scales comapred to materialized path or closure table patterns when thread depth gets past maybe 10-15 levels.

Expand full comment

No posts

Ready for more?