from Hacker News

Recursion with PostgreSQL, Follup 1, Perfomances

by vbilopav on 9/17/23, 1:43 PM with 1 comments

  • by vbilopav on 9/17/23, 1:43 PM

    I wrote a follow-up on yesterday's article on tree processing and recursion with PostgreSQL. This one: https://github.com/vb-consulting/blog/discussions/1

    SQL was never intended for this kind of stuff; I'm sure that Fabian Pascal will tell us all about it.

    And indeed, recursive CTEs are awful, confusing, and severely limited ... but they look cool and smart, and smart people use them (I hate them).

    In any case, I used a procedural approach to this problem and, with a few smart optimizations, managed to squeeze some really spectacular performances (757K tree records with 20K unique nodes in just 5 seconds without any indexes, so it probably can go even faster).