Query caching boosts the performance of PHP MySQL applications. Caching can be done on the database server or at the web clients. The mysqlnd plugin adds query caching to all PHP MySQL extension! It is fast, transparent and supports Memcache, APC, SQLite. Learn how to use its rich sets of performance statistics and how to identify cache candidates.
39. Accessing core statistics Change runtime configuration to collect statistics! array mysqlnd_qc_get_core_statistics() Returns a list of statistics collected by the core of the query cache plugin, if the PHP configuration setting mysqlnd_qc_collect_statistics is set to 1. The statistics are provided by the core and therefore available with all build-in storage handlers and when using user-defined storage handlers.
54. Manual aggregation using MySQL Fire and forget - works well for all kinds of QC stats! array mysqlnd_qc_get_core_statistics() Returns a list of statistics collected by the core of the query cache plugin, if the PHP configuration setting mysqlnd_qc_collect_statistics is set to 1. The statistics are provided by the core and therefore available with all build-in storage handlers and when using user-defined storage handlers.
64. Take care when calculating derived statistics. Handler with a storage life time beyond process scope may report cache_put = 0 together with cache_hit > 0, if another process has filled the cache. You may want to use “num_entries” from mysqlnd_cache_info(), given the handler supports it (Default, APC).
65.
66.
67.
68.
69. A value >0 indicates storage issues (errors, cache full, … - details are unknown)
103. Query back trace php.ini setting: mysqlnd_qc.collect_query_trace = 1 array mysqlnd_qc_get_query_trace_log() Returns a list query back traces for every query that has been inspected by the query cache regardless if the query ended up being cached or not. The trace tells you where a query has been issues (see also debug_backtrace()). Together with the back trace you get run and store times and information on if the query has been cached.
131. Normalized query back trace mysqlnd_qc.collect_normalized_query_trace = 1 array mysqlnd_qc_get_normalized_query_trace_log() Similar to mysqlnd_qc_get_query_trace_log() but with SQL statements normalized and aggregated by the normalized query string. Normalization refers to replacing actual parameters, for example in “WHERE a > 1”, with questionmarks like “ WHERE a > ?”. “WHERE a > ?” will match any value for “?”, for example “1”, “2”, “'abc'” but not other identifiers.
164. Accessing storage handler statistics User storage handler need to provide their own API! array mysqlnd_qc_get_cache_info() Returns information on the active handler and, if available, storage handler statistics. Storage handler statistics are provided under the “data” key of the hash. Different storage handler return different statistics, if any. User defined storage handler cannot return their statistics through this function. They need to provide their own API for accessing storage handler level statistics.