Database Reference
In-Depth Information
The problem here is that
TRADITIONAL
was spelled incorrectly; correct it and start the
server again.
How many queries is my server processing?
This question might be prompted by simple
curiosity, or there might be a performance issue. Monitoring statement execution over
time and summarizing the results can reveal patterns, such as a time of day or day of
week when activity is especially heavy. Perhaps several report generators are configured
to start at the same time. Staggering them will help your server by spreading the load.
To answer the “how many queries” question, use status variable information:
mysql>
SHOW GLOBAL STATUS LIKE 'Queries';
+---------------+----------+
| Variable_name | Value |
+---------------+----------+
| Queries | 65743031 |
+---------------+----------+
That tells you the number of statements executed since server startup, but it's an absolute
value. You'll likely find a rate more useful: get the
Uptime
value and determine the
Queries
/
Uptime
ratio for a rate in statements per second. For a rate in a different unit,
adjust the expression accordingly. For example, this tells you statements per minute:
mysql>
SHOW GLOBAL STATUS LIKE 'Uptime';
+---------------+----------+
| Variable_name | Value |
+---------------+----------+
| Uptime | 22164600 |
+---------------+----------+
mysql>
SELECT (65743031 * 60) / 22164600 AS 'statements/minute';
+-------------------+
| statements/minute |
+-------------------+
| 177.9677 |
+-------------------+
In programmatic context, you might write a long-running application that probes the
server periodically for the
Queries
and
Uptime
values, to determine a running display
of statement-execution activity. To avoid reconnecting each time you issue the state‐
ments, ask the server for its session timeout period and probe it at intervals shorter than
that value. To get the session timeout value (in seconds), use this statement:
SELECT
@@
wait_timeout
;
The default value is 28,800 (8 hours). If it's configured to a value shorter than your
desired probe interval, set it higher:
SET
wait_timeout
=
seconds
;