Oracle 5.0 Reference Manual page 2691

Table of Contents

Advertisement

INSERT INTO test(id) VALUES (1), (2), (3):
20.7.7.4.8. Measuring cache efficiency
Copyright 1997-2012 the PHP Documentation Group. [2230]
PECL/mysqlnd_qc offers three ways to measure the cache efficiency. The function
mysqlnd_qc_get_normalized_query_trace_log
query string,
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 mysqlnd_qc_get_core_stats.
The functions
mysqlnd_qc_get_core_stats
their corresponding PHP configuration directives. Data collection is disabled by default for performance
considerations. It is configurable with the
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.
Example 20.315. Collecting statistics data with the
mysqlnd_qc.enable_qc=1
mysqlnd_qc.collect_statistics=1
<?php
/* connect to MySQL */
$mysqli = new mysqli("host", "user", "password", "schema", "port", "socket");
$mysqli->query("DROP TABLE IF EXISTS test");
$mysqli->query("CREATE TABLE test(id INT)");
$mysqli->query("INSERT INTO test(id) VALUES (1), (2), (3)");
/* dummy queries */
for ($i = 1; $i <= 4; $i++) {
$query = sprintf("/*%s*/SELECT id FROM test WHERE id = %d", MYSQLND_QC_ENABLE_SWITCH, $i % 2);
$res
= $mysqli->query($query);
$res->free();
}
var_dump(mysqlnd_qc_get_core_stats());
?>
The above examples will output something similar to:
array(26) {
["cache_hit"]=>
string(1) "2"
["cache_miss"]=>
string(1) "2"
["cache_put"]=>
Mysqlnd query result cache plugin (mysqlnd_qc)
DROP TABLE IF EXISTS test:
CREATE TABLE test(id INT):
SELECT id FROM test WHERE id = 0:
SELECT id FROM test WHERE id = 1:
SELECT id FROM test WHERE id = 2:
mysqlnd_qc_get_cache_info
mysqlnd_qc_get_normalized_query_trace_log
will not collect data unless data collection has been enabled through
0ms (1x)
0ms (1x)
0ms (1x)
25ms (1x)
10ms (1x)
9ms (1x)
returns statistics aggregated by the normalized
gives storage handler specific information which
mysqlnd_qc.time_statistics
mysqlnd_qc.time_statistics
2671
and
option, which determines if timing
ini setting

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents