Bug #53494 Update docs for Queries and Questions in SHOW STATUS
Submitted: 7 May 2010 15:32 Modified: 26 May 2010 18:29
Reporter: Mark Callaghan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: queries, questions, show, STATUS
Triage: Triaged: D5 (Feature request)

[7 May 2010 15:32] Mark Callaghan
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.
[10 May 2010 13:34] Stefan Hinz
We can handle the documentation request; when done, category should be changed.
[19 May 2010 15:39] Paul Dubois
Docs updated. Changing category to Server:Options and Variables and unassigning myself.
[26 May 2010 18:29] Sveta Smirnova
Thank you for the report.

Verified as described. This is fixed in 5.5 series, although I could not find related bug report.