bin/XEtemplates/Count Query Locks.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<event_sessions xmlns="http://schemas.microsoft.com/sqlserver/2008/07/extendedeventconfig">
  <event_session name="Count Query Locks" maxMemory="4" eventRetentionMode="allowSingleEventLoss" trackCausality="true" dispatchLatency="30" maxEventSize="0" memoryPartitionMode="none">
    <templateCategory>
      <!-- _locID_text="templateCategory" _locComment = "" -->Locks and Blocks</templateCategory>
    <templateName>
      <!-- _locID_text = "templateName" _locComment = "" -->Count Query Locks</templateName>
    <templateDescription>
      <!-- _locID_text = "templateDescription" _locComment = "" -->Counts the number of locks acquired by each query based on the query_hash value. You can use this template to identify the most lock intensive queries for investigation and tuning.</templateDescription>
    <event package="sqlserver" name="lock_acquired">
      <action package="sqlserver" name="query_hash" />
      <predicate>
        <and>
          <leaf>
            <comparator name="greater_than_uint64" package="package0"></comparator>
            <event name="lock_acquired" package="sqlserver" field="database_id"></event>
            <value>4</value>
          </leaf>
          <leaf>
            <comparator name="equal_boolean" package="package0"></comparator>
            <global name="is_system" package="sqlserver"></global>
            <value>false</value>
          </leaf>
        </and>
      </predicate>
    </event>
    <target package="package0" name="histogram">
      <parameter name="filtering_event_name" value="sqlserver.lock_acquired" />
      <parameter name="source" value="sqlserver.query_hash" />
    </target>
  </event_session>
</event_sessions>