Stored procedure compilation?

  • Hi All,

    I am trying to understand what happens inside the Sql server when we create/re-compile any SP.

    I know that SQL server will use execution plans to when called the same SPs. What are these execution plans and how these are helping to speed up the subsequent Stored procedure executions?

    Thanks in advance,

    Suresh

    Regards,
    Suresh Arumugam

  • Short answer is that the compilation figures out how the execution of the stored procedure will occur, how tables will be accessed and how joins will be handled. It does this so that subsequent accesses don't have to "pay" for that step as sometimes it can take a second or two..

    CEWII

  • Huge topic. Someone should write a book.

    Execution plans, in short, are how SQL Server determines how it will access your data. They are reused if the query you're submitting matches a plan already created, but that's also dependent on the parameters being the same, which is why ad hoc sql that doesn't use parameters leads to poor plan reuse.

    ----------------------------------------------------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

  • Grant Fritchey (2/10/2010)


    Huge topic. Someone should write a book.

    You funny. 😛

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

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