The MySQL query cache is a special buffer, where database stores the text of a SELECT statement together with the corresponding result that was sent to the client. For as long as no table that a statement refers to changes in any way, including the contents, the cached result can be re-used to answer any identical sub-sequent SELECT statements. But how to tell whether a query was executed or returned from the cache?
There are at least three ways to check it.
MySQL exposes a number of runtime statistics that are accessible
SHOW STATUS statement. Among the long list of
various counters, one is called
shows how many times a SELECT statement was executed. However if
a SELECT is served from the query cache, it does not actually
execute, so it is not accounted in
conclusion must be that if a query runs, but it …