Skip to content
Advertisement

Converting recursive CTE from Postgre SQL to SQL Server

I am having trouble adapting some recursive CTE code from PostgreSQL to SQL Server.

Here is my table:

and what I am trying to adapt:

I have been having issues adapting the use of ARRAYs. Any pointers would be really helpful!

Advertisement

Answer

Much more quicker will be :

Tested with 100003 rows, the results are :

  • Charlieface Query 1 : 5′ 05″
  • Charlieface Query 2 : 4′ 58″
  • My own one : 0′ 01″

Running on a Windows 2019 Developper / PC with 256 Go RAM and 24 cores x 2 intel Xeon CPU E5-1650 v4

Conclusion : JSON or XML are very costly in recursive queries…

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement