标签:dmi code 连接 his server only 根据 glob use
Queries_per_sec (QPS)是数据库两个比较重要的性能计数器指标。我们经常要求开发告知这个参数,以评估数据库的一个负载情况。下面的这段代码连上服务器,做一个简单的查询:
using (MySqlConnection conn = new MySqlConnection())
{
conn.ConnectionString = "Database=xx;Host=xx;Port=xx;User Id=xx; Password=xx; charset=utf8;pooling=true;";
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
conn.Open();
cmd.CommandText = " select * from test where ID = 3";
cmd.ExecuteNonQuery();
conn.Close();
}
性能计数器是我们从show global status采集而来。其中的Questions和Queries定义如下:
Questions
The number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the Queries variable. This variable does not count COM_PING, COM_STATISTICS, COM_STMT_PREPARE, COM_STMT_CLOSE, or COM_STMT_RESET commands.
Queries
The number of statements executed by the server. This variable includes statements executed within stored programs, unlike the Questions variable. It does not count COM_PING or COM_STATISTICS commands.
3499308 Init DB testdb
3499308 Query select * from test where ID = 3
3499308 Init DB testdb
3499308 Query select * from test where ID = 3
1、Com_admin_commands
2、Com_change_db
3、Com_select
第二和第三比较好解释,Com_Change_DB相当于我们的Init DB, COM_Select就是我们的SELECT查询。而第一个Com_admin_commands就比较奇怪了。经查代码,这是下面的几计数器的集合。其他的一般都用不到,能用到的就剩下COM_PING了。
COM_CHANGE_USER
COM_SHUTDOWN
COM_PING
COM_DEBUG
COM_BINLOG_DUMP_GTID
COM_BINLOG_DUMP
Queries_per_sec 比我们预期的QPS高三倍,是由于驱动程序对连接有Ping的一个检验动作。这个动作应该也算作Queries。在Questions里体现不出来。
标签:dmi code 连接 his server only 根据 glob use
原文地址:https://www.cnblogs.com/CtripDBA/p/12254680.html