V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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
mahone3297
V2EX  ›  MySQL

[请教] mysql alter table 大表,数据库 io 不匹配的疑问

  •  
  •   mahone3297 · May 22, 2017 · 3701 views
    This topic created in 3266 days ago, the information mentioned may be changed or developed.

    mysql 版本 5.6.29

    • 通过 mysql 查询 db 大小

    select TABLE_NAME, TABLE_ROWS, DATA_LENGTH/1024/1024/1024, INDEX_LENGTH/1024/1024/1024 from information_schema.TABLES where TABLE_SCHEMA = 'XXX' order by DATA_LENGTH desc;

    table_name table_rows data_length index_length XXXLog 263376803 31.81933594 15.8056488

    • 执行 sql

    修改表字段长度

    ALTER TABLE XXXLog CHANGE remark remark VARCHAR(30) DEFAULT NULL;

    • 通过 iostat 观察 io 情况

    iostat -m 3 100000

    avg-cpu: %user %nice %system %iowait %steal %idle 17.97 0.00 7.01 0.05 0.00 74.96

    Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn sda 560.67 4.10 37.43 12 112

    • 疑问:

    ** db 服务器,用的 SSD 硬盘,速度才 37mb/s ?那么慢?是因为 alter 的时候,要计算,所以瓶颈在 cpu ?

    ** 37mb/s,一小时应该能跑数据 37*3600 = 130G,但我跑上面的 XXXLog 表( 31g data + 15g index ),执行了 1.5h 左右,为什么?

    2 replies    2017-05-26 09:49:52 +08:00
    mahone3297
        1
    mahone3297  
    OP
       May 23, 2017
    能否来点人,帮忙看看啊。。。请教啊。。。
    mahone3297
        2
    mahone3297  
    OP
       May 26, 2017
    没人懂? anybody ?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2535 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 09:03 · PVG 17:03 · LAX 02:03 · JFK 05:03
    ♥ Do have faith in what you're doing.