question

asid87 avatar image
asid87 asked

What are the implications of using CTE on large datasets

I know the basic functionality of CTE but would want to know if it is good to use on large data sets and what problems might it cause.
sql servercte
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
A CTE is nothing but a query. It doesn't have a positive or negative impact any more than any other type of derived table will. Despite the fact that the name includes the word Table, nothing is stored in a CTE. Using a CTE within a query is the same as using a sub-select. It's a query. The only exception to this is when using a CTE recursively. Recursive queries are, by their nature, somewhat problematic. Running them against very large data sets if you don't have good indexing and the query taking advantage of that indexing could be problematic. But the issue here is the recursion, not the CTE itself.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.