June 26, 2009 at 1:24 am
Recursive cte is powerful.
But the loop join will bring so many seeks if the anchor table has many rows.
I want to try a merge join instead of loop join, proper index can be quite efficient for merge join (both inputs are sorted).
But the truth is SQL Server ignores my hint and still use a loop join.
Is there's something wrong or it's by design ?
June 26, 2009 at 9:20 am
Just MHO, it is probably by design as recursion by nature is a loop.
June 26, 2009 at 1:51 pm
I could be wrong but I'd have to say it's because a recursive CTE is just the same as a While Loop (sometimes, it's worse). It's only going to process in a RBAR fashion and so can't do any kind of a join other than a loop join.
Perhaps if you told us what the code is trying to accomplish and actually post the code and some test data according to the link in my signature below, we could help you avoid the problem of RBAR code altogether.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply