April 19, 2012 at 7:09 pm
I have a stored procedure which first populates the CTE( about 230 records) and then reads off this CTE. When i look at the execution plan i see that the same plan which is used to populate CTE is being used again while reading the data from CTE. Is this how CTE works?
April 19, 2012 at 7:52 pm
How about providing the code and execution plan (as a .sqlplan file).
April 20, 2012 at 9:43 am
One neat little easter-egg about CTEs that I'll throw out there is that they can be executed multiples times if they are referenced multiple times by your query. It is up to the optimizer on how the query is evaluated and how many times a CTE "subquery" needs to be executed to satisfy the query when referenced multiple times. Are you referencing the CTE multiple times? Please post the code as requested.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply