› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
Inn0cence
V2EX  ›  MySQL

MYSQL 慢查询为什么会导致 CPU 占用率过高

  •  
  •   Inn0cence · Mar 31, 2020 · 4671 views
    This topic created in 2373 days ago, the information mentioned may be changed or developed.

    性能调优的过程中发现慢查询过多会导致 CPU 占用飙升, 假如我慢查询的原因是磁盘随机 IO 过多,这个瓶颈主要是在磁盘吧?为什么 CPU 占用也会飙升。

    5 replies  •  2020-04-05 23:58:37 +08:00
    msg7086
        1
    msg7086  
       Mar 31, 2020
    命题假设错误。
    很多慢查询是因为要扫表,也就是几十万条记录一个个看过去,有些是要先生成几十万条记录然后再查,所以很容易就吃光 CPU 导致慢查询了。
    Inn0cence
        2
    Inn0cence  
    OP
       Mar 31, 2020
    @msg7086 加了索引的情况下,扫描行数到不了这么高,但是 CPU 占用还是飙升
    sansanhehe
        3
    sansanhehe  
       Mar 31, 2020
    @Inn0cence 扫描行不多但是 CPU 依然高,有可能是每行数据包含的列较多,某些列的数据量比较大
    Inn0cence
        4
    Inn0cence  
    OP
       Mar 31, 2020
    @sansanhehe innodb 走索引,先是通过索引找到主键,再通过主键去查询记录,这个时候还和列有关啊?
    xcstream
        5
    xcstream  
       Apr 5, 2020
    就是查字典不看目录从第一页翻到最后一页,费脑子
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   931 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 19:46 · PVG 03:46 · LAX 12:46 · JFK 15:46
    ♥ Do have faith in what you're doing.