Is Recursive CTE SQL Server considered a loop?

I had the impression that recursive CTEs were set based, but in a recent SO post, someone mentioned that they are loops.

Are recursive CTEs installed based on? Am I mistaken in assuming that a set-based operation cannot be a loop?

+5
source share
3 answers

If it is recursive, it is still considered a loop. Despite the fact that one operator is installed on the basis, calling it again and again can be considered as a cycle. This is an argument regarding a definition or wording based on the context used. They are established on the basis of statements, but processing is considered simple cycle procedures.

For those who are interested, it is well written about performance using CTE:

http://explainextended.com/2009/11/18/sql-server-are-the-recursive-ctes-really-set-based/

+2
source

They are set based. Fractal sets are still sets.

, , . , , , . , . " " - . , SQL - , .

+2

, , , " " " ".

- .

Loop - .

Recursive CTEs are tail recursions and therefore essentially Loop. The only difference is that the termination condition is met using SQL semantics / execution engine. The output from each Loop iteration is UNIONed or whatever you specify.

0
source

All Articles