common Table(cte) in store procedure?

  • Hi,

    while writing store procedure in db

    most of Time i will Use common Table to write select quries

    for selecting more than seven table whether it reduce speed performance or it won't

    ;with cte

    {

    }

    Thanks & Regards

    SivaGanesh TamilVendhan

  • Sivaganesh Tamilvendhan (7/31/2014)


    Hi,

    while writing store procedure in db

    most of Time i will Use common Table to write select quries

    for selecting more than seven table whether it reduce speed performance or it won't

    ;with cte

    {

    }

    Thanks & Regards

    SivaGanesh TamilVendhan

    The CTE as such will not slow the code down, it's what in there and how it is used that matters.

    😎

  • A CTE is just a query. All by itself, it's not good, it's not bad. It's just a query. What will hurt performance is what you're querying, how you're querying it, the code, the structures, the indexes, constraints and statistics. Exactly the same as any other query. The one exception to all that is if you're using recursion with the CTE. Then, you may, depending on the query, see serious performance issues.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply