Oracle 5.0 Reference Manual page 2689

Table of Contents

Advertisement

20.7.7.4.7. Finding cache candidates
Copyright 1997-2012 the PHP Documentation Group. [2230]
A statement should be considered for caching if it is executed often and has a long run time. Cache
candidates are found by creating a list of statements sorted by the product of the number of executions
multiplied by the statements run time. The function
query log which help with the task.
Collecting a query trace is a slow operation. Thus, it is disabled by default. The PHP configuration
directive
mysqlnd_qc.collect_query_trace
entry for every query issued before the function is called.
Example 20.313. Collecting a query trace
mysqlnd_qc.enable_qc=1
mysqlnd_qc.collect_query_trace=1
<?php
/* connect to MySQL */
$mysqli = new mysqli("host", "user", "password", "schema", "port", "socket");
/* dummy queries to fill the query trace */
for ($i = 0; $i < 2; $i++) {
$res = $mysqli->query("SELECT 1 AS _one FROM DUAL");
$res->free();
}
/* dump trace */
var_dump(mysqlnd_qc_get_query_trace_log());
?>
The above examples will output:
array(2) {
[0]=>
array(8) {
["query"]=>
string(26) "SELECT 1 AS _one FROM DUAL"
["origin"]=>
string(102) "#0 qc.php(7): mysqli->query('SELECT 1 AS _on...')
#1 {main}"
["run_time"]=>
int(0)
["store_time"]=>
int(25)
["eligible_for_caching"]=>
bool(false)
["no_table"]=>
bool(false)
["was_added"]=>
bool(false)
["was_already_in_cache"]=>
bool(false)
}
[1]=>
array(8) {
["query"]=>
string(26) "SELECT 1 AS _one FROM DUAL"
["origin"]=>
string(102) "#0 qc.php(7): mysqli->query('SELECT 1 AS _on...')
#1 {main}"
Mysqlnd query result cache plugin (mysqlnd_qc)
2669
mysqlnd_qc_get_query_trace_log
is used to enable it. The functions trace contains one
returns a

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents