zoukankan      html  css  js  c++  java
  • sql_handle and plan_handle (读书笔记)

    The sys.dm_exec_cached_plan dmv contains a column called a plan_handle for every compiled plan. The plan_handle is a hashed value that derives from compiled plan of entire batch, and it is guaranteed to be unique for every currently exist compiled plan. The plan_handle can be used as an identifier for a compiled plan

    The actual SQL Test of a batch or objects is stored in another cache called the SQL Manager Cache(SQLMGR). The sql test associated with each batch is stored in its entirety, including all the comments. And it's can be retrieved using a data value called sql_handle. The sql_handle contains a hash of the entire batch text , and because it is unique for every batch, the sql_handle can serve as a identifier for the batch text in the SQLMGR cache .

    For specific sql test, it always has the same sql_handle, but it may not always have the same plan_handle. If the cache keys change, we'll get a new plan_handle in plan cache. The relationship between sql_handle and plan_handle is thus 1:N

    The following example indicates that one sql_handle maps two plan_handle because the SET option changed.

    dbcc freeproccache

    go

    SET CONCAT_NULL_YIELDS_NULL off

    go

    select top 1 null+'aa' from sys.objects

    go

    SET CONCAT_NULL_YIELDS_NULL on

    go

    select top 1 null+'aa' from sys.objects

    go

    select COUNT(plan_handle),sql_handle from sys.dm_exec_query_stats group by sql_handle

    go

  • 相关阅读:
    Python字符串
    MySQL触发器
    MySQL 1418报错解决办法
    数据库下载
    补码与反码
    二、八、十六进制之间的转换
    this 指向
    作用域 var 词法分析 arguments
    事件绑定的3种方式
    清浮动方法小结
  • 原文地址:https://www.cnblogs.com/stswordman/p/1537407.html
Copyright © 2011-2022 走看看