Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 9795

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Measuring cache efficiency</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd-qc.cache-candidates.html">Finding cache candidates</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlnd-qc.set-user-handlers.html">Beyond TTL: user-defined storage</a></div>
 <div class="up"><a href="mysqlnd-qc.quickstart.html">Quickstart and Examples</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqlnd-qc.cache-efficiency" class="section">
  <h2 class="title">Measuring cache efficiency</h2>
  <p class="para">
   PECL/mysqlnd_qc offers three ways to measure the cache efficiency.
   The function
    <span class="function"><a href="function.mysqlnd-qc-get-normalized-query-trace-log.html" class="function">mysqlnd_qc_get_normalized_query_trace_log()</a></span>
   returns statistics aggregated by the normalized query string,
    <span class="function"><a href="function.mysqlnd-qc-get-cache-info.html" class="function">mysqlnd_qc_get_cache_info()</a></span>
   gives storage handler specific information which includes a list
   of all cached items, depending on the storage handler. Additionally, the
   core of PECL/mysqlnd_qc collects high-level summary statistics aggregated
   per PHP process. The high-level statistics are returned by
    <span class="function"><a href="function.mysqlnd-qc-get-core-stats.html" class="function">mysqlnd_qc_get_core_stats()</a></span>.
  </p>
  <p class="para">
   The functions
    <span class="function"><a href="function.mysqlnd-qc-get-normalized-query-trace-log.html" class="function">mysqlnd_qc_get_normalized_query_trace_log()</a></span>
   and
    <span class="function"><a href="function.mysqlnd-qc-get-core-stats.html" class="function">mysqlnd_qc_get_core_stats()</a></span>
   will not collect data unless data collection has been
   enabled through their corresponding PHP configuration directives. Data collection
   is disabled by default for performance considerations. It is configurable with the
   <a href="mysqlnd-qc.configuration.html#ini.mysqlnd-qc.time-statistics" class="link">mysqlnd_qc.time_statistics</a> 
   option, which determines if timing information should be collected.
   Collection of time statistics is enabled by default
   but only performed if data collection as such has been enabled.
   Recording time statistics causes extra system calls. In most cases,
   the benefit of the monitoring outweighs any potential performance penalty of
   the additional system calls.
  </p>
  <p class="para">
   <div class="example" id="example-1856">
    <p><strong>Example #1 Collecting statistics data with the <em>mysqlnd_qc.time_statistics</em> ini setting</strong></p>
    <div class="example-contents">
<div class="inicode"><pre class="inicode">mysqlnd_qc.enable_qc=1
mysqlnd_qc.collect_statistics=1</pre>
</div>
    </div>

    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;connect&nbsp;to&nbsp;MySQL&nbsp;*/<br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"host"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"schema"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"port"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"socket"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP&nbsp;TABLE&nbsp;IF&nbsp;EXISTS&nbsp;test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;test(id&nbsp;INT)"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;test(id)&nbsp;VALUES&nbsp;(1),&nbsp;(2),&nbsp;(3)"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;dummy&nbsp;queries&nbsp;*/<br /></span><span style="color: #007700">for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;=&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"/*%s*/SELECT&nbsp;id&nbsp;FROM&nbsp;test&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;%d"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">%&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">free</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">mysqlnd_qc_get_core_stats</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above examples will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(26) {
  [&quot;cache_hit&quot;]=&gt;
  string(1) &quot;2&quot;
  [&quot;cache_miss&quot;]=&gt;
  string(1) &quot;2&quot;
  [&quot;cache_put&quot;]=&gt;
  string(1) &quot;2&quot;
  [&quot;query_should_cache&quot;]=&gt;
  string(1) &quot;4&quot;
  [&quot;query_should_not_cache&quot;]=&gt;
  string(1) &quot;3&quot;
  [&quot;query_not_cached&quot;]=&gt;
  string(1) &quot;3&quot;
  [&quot;query_could_cache&quot;]=&gt;
  string(1) &quot;4&quot;
  [&quot;query_found_in_cache&quot;]=&gt;
  string(1) &quot;2&quot;
  [&quot;query_uncached_other&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;query_uncached_no_table&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;query_uncached_no_result&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;query_uncached_use_result&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;query_aggr_run_time_cache_hit&quot;]=&gt;
  string(2) &quot;28&quot;
  [&quot;query_aggr_run_time_cache_put&quot;]=&gt;
  string(3) &quot;900&quot;
  [&quot;query_aggr_run_time_total&quot;]=&gt;
  string(3) &quot;928&quot;
  [&quot;query_aggr_store_time_cache_hit&quot;]=&gt;
  string(2) &quot;14&quot;
  [&quot;query_aggr_store_time_cache_put&quot;]=&gt;
  string(2) &quot;40&quot;
  [&quot;query_aggr_store_time_total&quot;]=&gt;
  string(2) &quot;54&quot;
  [&quot;receive_bytes_recorded&quot;]=&gt;
  string(3) &quot;136&quot;
  [&quot;receive_bytes_replayed&quot;]=&gt;
  string(3) &quot;136&quot;
  [&quot;send_bytes_recorded&quot;]=&gt;
  string(2) &quot;84&quot;
  [&quot;send_bytes_replayed&quot;]=&gt;
  string(2) &quot;84&quot;
  [&quot;slam_stale_refresh&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;slam_stale_hit&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;request_counter&quot;]=&gt;
  int(1)
  [&quot;process_hash&quot;]=&gt;
  int(1929695233)
}
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   For a quick overview, call
    <span class="function"><a href="function.mysqlnd-qc-get-core-stats.html" class="function">mysqlnd_qc_get_core_stats()</a></span>. It delivers
   cache usage, cache timing and traffic related statistics. Values are aggregated
   on a per process basis for all queries issued by any PHP MySQL API call.
  </p>
  <p class="para">
   Some storage handler, such as the default handler, can report cache entries,
   statistics related to the entries and meta data for the underlying query through the
    <span class="function"><a href="function.mysqlnd-qc-get-cache-info.html" class="function">mysqlnd_qc_get_cache_info()</a></span>
   function.  Please note, that the information returned depends
   on the storage handler. Values are aggregated on a per process basis.
  </p>
  <p class="para">
   <div class="example" id="example-1857">
    <p><strong>Example #2 Example  <span class="function"><a href="function.mysqlnd-qc-get-cache-info.html" class="function">mysqlnd_qc_get_cache_info()</a></span> usage</strong></p>
    <div class="example-contents">
<div class="inicode"><pre class="inicode">mysqlnd_qc.enable_qc=1</pre>
</div>
    </div>

    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;connect&nbsp;to&nbsp;MySQL&nbsp;*/<br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"host"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"schema"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"port"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"socket"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP&nbsp;TABLE&nbsp;IF&nbsp;EXISTS&nbsp;test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;test(id&nbsp;INT)"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;test(id)&nbsp;VALUES&nbsp;(1),&nbsp;(2),&nbsp;(3)"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;dummy&nbsp;queries&nbsp;to&nbsp;fill&nbsp;the&nbsp;query&nbsp;trace&nbsp;*/<br /></span><span style="color: #007700">for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;=&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"/*%s*/SELECT&nbsp;id&nbsp;FROM&nbsp;test&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;%d"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">%&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">free</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">mysqlnd_qc_get_cache_info</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above examples will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [&quot;num_entries&quot;]=&gt;
  int(2)
  [&quot;handler&quot;]=&gt;
  string(7) &quot;default&quot;
  [&quot;handler_version&quot;]=&gt;
  string(5) &quot;1.0.0&quot;
  [&quot;data&quot;]=&gt;
  array(2) {
    [&quot;Localhost via UNIX socket
3306
root
test|/*qc=on*/SELECT id FROM test WHERE id = 1&quot;]=&gt;
    array(2) {
      [&quot;statistics&quot;]=&gt;
      array(11) {
        [&quot;rows&quot;]=&gt;
        int(1)
        [&quot;stored_size&quot;]=&gt;
        int(71)
        [&quot;cache_hits&quot;]=&gt;
        int(1)
        [&quot;run_time&quot;]=&gt;
        int(391)
        [&quot;store_time&quot;]=&gt;
        int(27)
        [&quot;min_run_time&quot;]=&gt;
        int(16)
        [&quot;max_run_time&quot;]=&gt;
        int(16)
        [&quot;min_store_time&quot;]=&gt;
        int(8)
        [&quot;max_store_time&quot;]=&gt;
        int(8)
        [&quot;avg_run_time&quot;]=&gt;
        int(8)
        [&quot;avg_store_time&quot;]=&gt;
        int(4)
      }
      [&quot;metadata&quot;]=&gt;
      array(1) {
        [0]=&gt;
        array(8) {
          [&quot;name&quot;]=&gt;
          string(2) &quot;id&quot;
          [&quot;orig_name&quot;]=&gt;
          string(2) &quot;id&quot;
          [&quot;table&quot;]=&gt;
          string(4) &quot;test&quot;
          [&quot;orig_table&quot;]=&gt;
          string(4) &quot;test&quot;
          [&quot;db&quot;]=&gt;
          string(4) &quot;test&quot;
          [&quot;max_length&quot;]=&gt;
          int(1)
          [&quot;length&quot;]=&gt;
          int(11)
          [&quot;type&quot;]=&gt;
          int(3)
        }
      }
    }
    [&quot;Localhost via UNIX socket
3306
root
test|/*qc=on*/SELECT id FROM test WHERE id = 0&quot;]=&gt;
    array(2) {
      [&quot;statistics&quot;]=&gt;
      array(11) {
        [&quot;rows&quot;]=&gt;
        int(0)
        [&quot;stored_size&quot;]=&gt;
        int(65)
        [&quot;cache_hits&quot;]=&gt;
        int(1)
        [&quot;run_time&quot;]=&gt;
        int(299)
        [&quot;store_time&quot;]=&gt;
        int(13)
        [&quot;min_run_time&quot;]=&gt;
        int(11)
        [&quot;max_run_time&quot;]=&gt;
        int(11)
        [&quot;min_store_time&quot;]=&gt;
        int(6)
        [&quot;max_store_time&quot;]=&gt;
        int(6)
        [&quot;avg_run_time&quot;]=&gt;
        int(5)
        [&quot;avg_store_time&quot;]=&gt;
        int(3)
      }
      [&quot;metadata&quot;]=&gt;
      array(1) {
        [0]=&gt;
        array(8) {
          [&quot;name&quot;]=&gt;
          string(2) &quot;id&quot;
          [&quot;orig_name&quot;]=&gt;
          string(2) &quot;id&quot;
          [&quot;table&quot;]=&gt;
          string(4) &quot;test&quot;
          [&quot;orig_table&quot;]=&gt;
          string(4) &quot;test&quot;
          [&quot;db&quot;]=&gt;
          string(4) &quot;test&quot;
          [&quot;max_length&quot;]=&gt;
          int(0)
          [&quot;length&quot;]=&gt;
          int(11)
          [&quot;type&quot;]=&gt;
          int(3)
        }
      }
    }
  }
}
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   It is possible to further break down the granularity of statistics
   to the level of the normalized statement string.
   The normalized statement string is the statements string with all parameters
   replaced with question marks. For example, the two statements
   <em>SELECT id FROM test WHERE id = 0</em> and
   <em>SELECT id FROM test WHERE id = 1</em> are normalized into
   <em>SELECT id FROM test WHERE id = ?</em>. Their both
   statistics are aggregated into one entry for
   <em>SELECT id FROM test WHERE id = ?</em>.
  </p>
  <p class="para">
   <div class="example" id="example-1858">
    <p><strong>Example #3 Example  <span class="function"><a href="function.mysqlnd-qc-get-normalized-query-trace-log.html" class="function">mysqlnd_qc_get_normalized_query_trace_log()</a></span> usage</strong></p>
    <div class="example-contents">
<div class="inicode"><pre class="inicode">mysqlnd_qc.enable_qc=1
mysqlnd_qc.collect_normalized_query_trace=1</pre>
</div>
    </div>

    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;connect&nbsp;to&nbsp;MySQL&nbsp;*/<br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"host"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"schema"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"port"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"socket"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP&nbsp;TABLE&nbsp;IF&nbsp;EXISTS&nbsp;test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;test(id&nbsp;INT)"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;test(id)&nbsp;VALUES&nbsp;(1),&nbsp;(2),&nbsp;(3)"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;dummy&nbsp;queries&nbsp;to&nbsp;fill&nbsp;the&nbsp;query&nbsp;trace&nbsp;*/<br /></span><span style="color: #007700">for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;=&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"/*%s*/SELECT&nbsp;id&nbsp;FROM&nbsp;test&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;%d"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">%&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">free</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">mysqlnd_qc_get_normalized_query_trace_log</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above examples will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [0]=&gt;
  array(9) {
    [&quot;query&quot;]=&gt;
    string(25) &quot;DROP TABLE IF EXISTS test&quot;
    [&quot;occurences&quot;]=&gt;
    int(0)
    [&quot;eligible_for_caching&quot;]=&gt;
    bool(false)
    [&quot;avg_run_time&quot;]=&gt;
    int(0)
    [&quot;min_run_time&quot;]=&gt;
    int(0)
    [&quot;max_run_time&quot;]=&gt;
    int(0)
    [&quot;avg_store_time&quot;]=&gt;
    int(0)
    [&quot;min_store_time&quot;]=&gt;
    int(0)
    [&quot;max_store_time&quot;]=&gt;
    int(0)
  }
  [1]=&gt;
  array(9) {
    [&quot;query&quot;]=&gt;
    string(27) &quot;CREATE TABLE test (id INT )&quot;
    [&quot;occurences&quot;]=&gt;
    int(0)
    [&quot;eligible_for_caching&quot;]=&gt;
    bool(false)
    [&quot;avg_run_time&quot;]=&gt;
    int(0)
    [&quot;min_run_time&quot;]=&gt;
    int(0)
    [&quot;max_run_time&quot;]=&gt;
    int(0)
    [&quot;avg_store_time&quot;]=&gt;
    int(0)
    [&quot;min_store_time&quot;]=&gt;
    int(0)
    [&quot;max_store_time&quot;]=&gt;
    int(0)
  }
  [2]=&gt;
  array(9) {
    [&quot;query&quot;]=&gt;
    string(46) &quot;INSERT INTO test (id ) VALUES (? ), (? ), (? )&quot;
    [&quot;occurences&quot;]=&gt;
    int(0)
    [&quot;eligible_for_caching&quot;]=&gt;
    bool(false)
    [&quot;avg_run_time&quot;]=&gt;
    int(0)
    [&quot;min_run_time&quot;]=&gt;
    int(0)
    [&quot;max_run_time&quot;]=&gt;
    int(0)
    [&quot;avg_store_time&quot;]=&gt;
    int(0)
    [&quot;min_store_time&quot;]=&gt;
    int(0)
    [&quot;max_store_time&quot;]=&gt;
    int(0)
  }
  [3]=&gt;
  array(9) {
    [&quot;query&quot;]=&gt;
    string(31) &quot;SELECT id FROM test WHERE id =?&quot;
    [&quot;occurences&quot;]=&gt;
    int(4)
    [&quot;eligible_for_caching&quot;]=&gt;
    bool(true)
    [&quot;avg_run_time&quot;]=&gt;
    int(179)
    [&quot;min_run_time&quot;]=&gt;
    int(11)
    [&quot;max_run_time&quot;]=&gt;
    int(393)
    [&quot;avg_store_time&quot;]=&gt;
    int(12)
    [&quot;min_store_time&quot;]=&gt;
    int(7)
    [&quot;max_store_time&quot;]=&gt;
    int(25)
  }
}
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   The source distribution of PECL/mysqlnd_qc contains a directory
   <em>web/</em> in which web based monitoring
   scripts can be found which give an example how to write a cache monitor.
   Please, follow the instructions given in the source.
  </p>
  <p class="para">
   Since PECL/mysqlnd_qc 1.1.0 it is possible to write statistics into a
   log file. Please, see <em><a href="mysqlnd-qc.configuration.html#ini.mysqlnd-qc.collect-statistics-log-file" class="link">
   mysqlnd_qc.collect_statistics_log_file</a></em>.
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd-qc.cache-candidates.html">Finding cache candidates</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlnd-qc.set-user-handlers.html">Beyond TTL: user-defined storage</a></div>
 <div class="up"><a href="mysqlnd-qc.quickstart.html">Quickstart and Examples</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>