• drew.allen (1/11/2012)


    If you read the article, you'll see that even the mere 4000 row CTE has a significant performance impact. That's how badly recursive CTEs can perform.

    You might have missed that I quoted the performance impact directly from the article "(150ms from Jeff's article graph)", which is one I have read many times (see the article's discussion thread for my comments). 150ms is not 'significant' in the current context, and it is 46ms on my laptop in any case:

    SET STATISTICS TIME ON;

    WITH R AS (SELECT 1 AS N UNION ALL SELECT R.N + 1 FROM R WHERE R.N <= 4000)

    SELECT * INTO #bucket FROM R OPTION (MAXRECURSION 0)

    SET STATISTICS TIME OFF;