Mysql慢查询日志表明表中行数很少,性能低下

标签 mysql mysql-slow-query-log

explain extended  SELECT check_fine from local_profiles WHERE (name = 'myprofile');

+----+-------------+-----------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table           | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
+----+-------------+-----------------+------+---------------+------+---------+------+------+----------+-------------+ 
|  1 | SIMPLE      | local_profiles  | ALL  | NULL          | NULL | NULL    | NULL |    1 |   100.00 | Using where |
+----+-------------+-----------------+------+---------------+------+---------+------+------+----------+-------------+

+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int(11)      | NO   | PRI | NULL    | auto_increment |
| name         | varchar(256) | NO   |     | NULL    |                |
| check_fine   | tinyint(4)   | NO   |     | 0       |                |
+--------------+--------------+------+-----+---------+----------------+

mysql慢查询日志设置(log-queries-not-using-indexes = 0)

# Query 10: 0.03 QPS, 0.19x concurrency, ID xxxxxxxxxxxxxxxxx at byte 53863711
# This item is included in the report because it matches --outliers.
# Scores: V/M = 1.17


# Rank Query ID           Response time     Calls R/Call  V/M   Item
# ==== ================== ================= ===== ======= ===== ==========
#    5 xxxxxxxxxxxxxxxxx  16710.3680  1.8%  2203  7.5853  1.17 SELECT local_profiles


# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          1    2468
# Exec time      1  18379s      5s     33s      7s     13s      3s      6s
# Lock time      0   471ms    64us    32ms   258us   259us   896us    90us
# Rows sent      0   1.16k       0       1    0.54    0.99    0.49    0.99
# Rows examine   0   1.16k       0       1    0.54    0.99    0.49    0.99
# Query size     0 121.71k      57      57      57      57       0      57
  1. 我有一个只有五行三列的表。然而上面提到的简单查询是在mysql慢查询日志中显示的。

这个简单的查询将如何影响性能。

  • 是什么意思 此项目包含在报告中,因为它与 --outliers 匹配

    在此处输入代码

  • 最佳答案

    我可以回答两个问题之一...

    2. what does mean by This item is included in the report because it matches --outliers

    这看起来像 pt-query-digest 的输出其中有 --outliers option 。它用于控制哪些查询被报告为缓慢。它需要参数,因此选择此查询的原因取决于传递给它的内容。

    关于Mysql慢查询日志表明表中行数很少,性能低下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36067084/

    相关文章:

    mysql - MySQL Replication Server 可以启用日志查询吗?

    php - 在 Laravel 5.3 中找不到基表或 View

    mysql - mongoDB vs mySQL——为什么在某些方面比另一个更好

    php - 带查询的日期数组

    php - 按类别对 mysqli/PDO 结果进行分组并将其显示到组中

    MySQL 5.7 : Why are 38% of queries missing from the slow query log?

    mysql - 如何显示来自 3 个连接的单个项目的记录或数据

    Mysql、hibernate slow_query_log日志设置时间戳

    mysql - 实时记录MySQL慢查询

    Mysql慢查询组与子查询连接