<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-table-handles-table">
      </a>
      29.12.13.4 The table_handles Table
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045070243152">
  </a>
  <a class="indexterm" name="idm46045070241664">
  </a>
  <p>
   The Performance Schema exposes table lock information through
          the
   <a class="link" href="performance-schema-table-handles-table.html" title="29.12.13.4 The table_handles Table">
    <code class="literal">
     table_handles
    </code>
   </a>
   table to show
          the table locks currently in effect for each opened table
          handle.
   <a class="link" href="performance-schema-table-handles-table.html" title="29.12.13.4 The table_handles Table">
    <code class="literal">
     table_handles
    </code>
   </a>
   reports
          what is recorded by the table lock instrumentation. This
          information shows which table handles the server has open, how
          they are locked, and by which sessions.
  </p>
  <p>
   The
   <a class="link" href="performance-schema-table-handles-table.html" title="29.12.13.4 The table_handles Table">
    <code class="literal">
     table_handles
    </code>
   </a>
   table is read
          only and cannot be updated. It is autosized by default; to
          configure the table size, set the
   <a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_table_handles">
    <code class="literal">
     performance_schema_max_table_handles
    </code>
   </a>
   system variable at server startup.
  </p>
  <p>
   Table lock instrumentation uses the
   <code class="literal">
    wait/lock/table/sql/handler
   </code>
   instrument,
          which is enabled by default.
  </p>
  <p>
   To control table lock instrumentation state at server startup,
          use lines like these in your
   <code class="filename">
    my.cnf
   </code>
   file:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa3856122"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'wait/lock/table/sql/handler=ON'</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Disable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa95880921"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'wait/lock/table/sql/handler=OFF'</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   To control table lock instrumentation state at runtime, update
          the
   <a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
    <code class="literal">
     setup_instruments
    </code>
   </a>
   table:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34564289"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">=</span> <span class="token string">'wait/lock/table/sql/handler'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Disable:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34924734"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">=</span> <span class="token string">'wait/lock/table/sql/handler'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-table-handles-table.html" title="29.12.13.4 The table_handles Table">
    <code class="literal">
     table_handles
    </code>
   </a>
   table has these
          columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       OBJECT_TYPE
      </code>
     </p>
     <p>
      The table opened by a table handle.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OBJECT_SCHEMA
      </code>
     </p>
     <p>
      The schema that contains the object.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OBJECT_NAME
      </code>
     </p>
     <p>
      The name of the instrumented object.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OBJECT_INSTANCE_BEGIN
      </code>
     </p>
     <p>
      The table handle address in memory.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OWNER_THREAD_ID
      </code>
     </p>
     <p>
      The thread owning the table handle.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OWNER_EVENT_ID
      </code>
     </p>
     <p>
      The event which caused the table handle to be opened.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       INTERNAL_LOCK
      </code>
     </p>
     <p>
      The table lock used at the SQL level. The value is one of
      <code class="literal">
       READ
      </code>
      ,
      <code class="literal">
       READ WITH SHARED
              LOCKS
      </code>
      ,
      <code class="literal">
       READ HIGH PRIORITY
      </code>
      ,
      <code class="literal">
       READ NO INSERT
      </code>
      ,
      <code class="literal">
       WRITE ALLOW
              WRITE
      </code>
      ,
      <code class="literal">
       WRITE CONCURRENT
              INSERT
      </code>
      ,
      <code class="literal">
       WRITE LOW PRIORITY
      </code>
      ,
              or
      <code class="literal">
       WRITE
      </code>
      . For information about these
              lock types, see the
      <code class="filename">
       include/thr_lock.h
      </code>
      source file.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       EXTERNAL_LOCK
      </code>
     </p>
     <p>
      The table lock used at the storage engine level. The value
              is one of
      <code class="literal">
       READ EXTERNAL
      </code>
      or
      <code class="literal">
       WRITE EXTERNAL
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-table-handles-table.html" title="29.12.13.4 The table_handles Table">
    <code class="literal">
     table_handles
    </code>
   </a>
   table has these
          indexes:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Primary key on (
      <code class="literal">
       OBJECT_INSTANCE_BEGIN
      </code>
      )
     </p>
    </li>
    <li class="listitem">
     <p>
      Index on (
      <code class="literal">
       OBJECT_TYPE
      </code>
      ,
      <code class="literal">
       OBJECT_SCHEMA
      </code>
      ,
      <code class="literal">
       OBJECT_NAME
      </code>
      )
     </p>
    </li>
    <li class="listitem">
     <p>
      Index on (
      <code class="literal">
       OWNER_THREAD_ID
      </code>
      ,
      <code class="literal">
       OWNER_EVENT_ID
      </code>
      )
     </p>
    </li>
   </ul>
  </div>
  <p>
   <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
    <code class="literal">
     TRUNCATE TABLE
    </code>
   </a>
   is not permitted
          for the
   <a class="link" href="performance-schema-table-handles-table.html" title="29.12.13.4 The table_handles Table">
    <code class="literal">
     table_handles
    </code>
   </a>
   table.
  </p>
 </div>
 <br/>
</div>
