Description:
I don't think these descriptions are sufficient:
http://dev.mysql.com/doc/refman/5.1/en/server-status-variables.html#statvar_Queries
The claim about stored procedures appears to be correct.
The problems are:
* Queries and Questions counts are not incremented for COM_STATISTICS and COM_PING
* Questions count is not incremented for COM_STMT_{PREPARE,CLOSE,RESET}
Additionally, I don't think it is a good idea to have commands (COM_STATISTICS, COM_PING) for which the global counters are not incremented. I know that command-specific COM_ counters in SHOW STATUS should incremented in that case, but most people will not know to look there when a server is getting a storm of COM_PING and COM_STATISTICS requests.
Queries
The number of statements executed by the server. This variable includes statements executed within stored programs, unlike the Questions variable. This variable was added in MySQL 5.1.31.
Questions
The number of statements executed by the server. As of MySQL 5.1.31, this includes only statements sent to the server by clients and no longer includes statements executed within stored programs, unlike the Queries variable.
How to repeat:
Read the code for dispatch_command() in sql_parse.cc:
switch( command ) {
/* Ignore these statements. */
case COM_STATISTICS:
case COM_PING:
break;
/* Only increase id on these statements but don't count them. */
case COM_STMT_PREPARE:
case COM_STMT_CLOSE:
case COM_STMT_RESET:
next_query_id();
break;
/* Increase id and count all other statements. */
default:
statistic_increment(thd->status_var.questions, &LOCK_status);
next_query_id();
}
Suggested fix:
Add yet another counter to SHOW STATUS to count all commands run.
Update the docs to specify the COM commands that are not counted.