What does Plan_Handle Specifies?

  • Hi,

    I am a newbie.I was going around DMV and found out Plan_Handle. I find out that this column is used in most of the DMV . I tried to find out what does that mean on internet but not much information is given.The language specified on msdn website giving explanation about Plan_Handle is quite high by my measures.

    I am not able to get what does that Hex-Code Means.

  • It doesn't mean much, it's just used to join several of the plan-related DMVs together.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi GilaMonster,

    Then what does that hex-codes specifies. Any good resource where i can get the information about the DMV. I mean good resource so do not suggest MSDN 🙂

  • I am going to suggest MSDN, because it is a good resource. All the DMVs are well documented there. Start with sys.dm_exec_cached_plans and have a look at all related DMVs.

    Again, the plan handle is just a binary identifier. It just identifies a plan.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • In msdn i was looking for sys.dm_exec_query_stats in that there is a column name 'statement_start_offset' . Explanation of it is given as '.....the starting position of the query that the row describes within the text of its batch or persisted object.' .

    Now in this case what does "batch or persisted object."

  • Batch - current batch of SQL statements (set of statements sent to the server) http://msdn.microsoft.com/en-us/library/ms175502%28v=sql.105%29.aspx

    Persisted object - stored procedure, function or trigger.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks man 🙂

  • Hi Gila,

    Further into MSDN i found out the defination execution_count it is given as "Number of times that the plan has been executed since it was last compiled." So could you please tell me what does it mean by "Was last compiled".

    I know that we execute the query but compiled:unsure:

  • Compiled = plan generated by the optimiser. So that's the number of times that the procedure has been executed since the current execution plan was compiled by the optimiser.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Please pardon me if i am wrong but isn't the query plan generated just when we press the execute button, if yes then that means every time plan is generated the query is executed.

  • No. http://msdn.microsoft.com/en-us/library/ee343986%28v=sql.100%29.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 11 posts - 1 through 10 (of 10 total)

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