Databases Reference
In-Depth Information
Command Counters
The Com_* variables count the number of times each type of SQL or C API command
has been issued. For example, Com_select counts the number of SELECT statements, and
Com_change_db counts the number of times a connection's default database has been
changed, either with the USE statement or via a C API call. The Questions variable 3
counts the total number of queries and commands the server has received. However,
it doesn't quite equal the sum of all the Com_* variables, because of query cache hits,
closed and aborted connections, and possibly other factors.
The Com_admin_commands status variable might be very large. It counts not only admin-
istrative commands, but ping requests to the MySQL instance as well. These requests
are issued through the C API and typically come from client code, such as the following
Perl code:
my $dbh = DBI->connect(...);
while ( $dbh && $dbh->ping ) {
# Do something
}
These ping requests are “garbage” queries. They usually don't load the server very
much, but they're still a waste and contribute a lot to application response time because
of the network round trip time. We've seen ORM systems (Ruby on Rails comes to
mind) that ping the server before each query, which is pointless; pinging the server and
then querying it is a classic example of the “look before you leap” design pattern, which
creates a race condition. We've also seen database abstraction libraries that change the
default database before every query, which will show up as a very large number of
Com_change_db commands. It's best to eliminate both practices.
Temporary Files and Tables
You can view the variables that count how many times MySQL has created temporary
tables and files with:
mysql> SHOW GLOBAL STATUS LIKE 'Created_tmp%';
This shows statistics about implicit temporary tables and files—those created internally
to execute queries. In Percona Server, there is also a command that can show explicit
temporary tables, which are created by users with CREATE TEMPORARY TABLE :
mysql> SHOW GLOBAL TEMPORARY TABLES ;
3. In MySQL 5.1, this variable was split into Questions and Queries , with slightly different meanings.
 
Search WWH ::




Custom Search