MySQL 如何衡量“每秒查询数”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4737047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:22:45  来源:igfitidea点击:

How to measure "queries per second"?

mysqlquery-optimization

提问by Silver Light

In literature SQL query efficiency is often measured in "queries pre second" (QPS). How those measures are made, considering that I have a database with production data at my hands? Is there a MySQL tool that can to this?

在文献中,SQL 查询效率通常以“每秒查询数”(QPS) 来衡量。考虑到我手头有一个包含生产数据的数据库,这些措施是如何制定的?有没有可以做到这一点的 MySQL 工具?

回答by shantanuo

 # mysqladmin status

Uptime: 587  Threads: 121  Questions: 3456  Slow queries: 0  Opens: 152  Flush tables: 1  Open tables: 64  Queries per second avg: 5.888

回答by Kibbee

The easiest way to do this is to create a job that runs:

最简单的方法是创建一个运行的作业:

SHOW STATUS

at specified intervals. This will return the "queries" value. Take the difference between successive calls to SHOW STATUS and then divide by the number of seconds between measurements to get the queries per second.

在指定的时间间隔。这将返回“查询”值。取 SHOW STATUS 连续调用之间的差异,然后除以测量之间的秒数以获取每秒查询数。

回答by Geoffrey Wagner

If you are on linux, you can use a tool called MyTop for realtime analytics.

如果您使用的是 Linux,则可以使用名为 MyTop 的工具进行实时分析。

回答by sdesvergez

Playing with #service mysql statusreturns those informations (based on mysqladmin binary) :

使用#service mysql status返回这些信息(基于 mysqladmin 二进制文件):

root@SERVER:~# service mysql status
[info] /usr/bin/mysqladmin  Ver 8.42 Distrib 5.5.44, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version          5.5.44-0+deb7u1
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 1 day 6 hours 36 min 1 sec

Threads: 2  Questions: 332928  Slow queries: 0  Opens: 104  Flush tables: 1  Open tables: 59  Queries per second avg: 3.022.