MySQL 管理工具集 percona-toolkit
apt-get install -y percona-toolkit
# 检查重复索引
pt-duplicate-key-checker -host=’sohu.dev.chenpeng.info’ -port=’43307′ -databases=’grape’
# 运行状态监控
pt-mysql-summary -host=’sohu.dev.chenpeng.info’ -port=’43307′ -databases=’grape’
# 在线修改表结构
pt-online-schema-change -host=’sohu.dev.chenpeng.info’ -port=’3306′ -alter “ADD COLUMN c1 INT” D=chenpeng_litchi,t=lc_operate_log -execute -print
pt-online-schema-change -host=’sohu.dev.chenpeng.info’ -port=’3306′ -alter “ENGINE=InnoDB” D=chenpeng_litchi,t=lc_operate_log -execute -print
# 格式化explain结果
mysql -hsohu.dev.chenpeng.info -P43307 grape -e”explain SELECT a.line_id,b.dnf_source FROM gp_report_advertiser_day a INNER JOIN gp_line b ON a.line_id=b.id WHERE a.data_date=’2016-04-10′ LIMIT 100″ | pt-visual-explain
重复索引结果示例:
# ########################################################################
# grape.gp_mars_report_advertiser_hour
# ########################################################################
# line_id is a left-prefix of line_id_data_time
# Key definitions:
# KEY `line_id` (`line_id`) USING BTREE,
# KEY `line_id_data_time` (`line_id`,`data_time`) USING BTREE
# Column types:
# `line_id` bigint(20) unsigned not null comment ‘??id’
# `data_time` datetime not null comment ‘??’
# To remove this duplicate index, execute:
ALTER TABLE `grape`.`gp_mars_report_advertiser_hour` DROP INDEX `line_id`;
# ########################################################################
# grape.gp_operate_log
# ########################################################################
# related_id is a left-prefix of search3
# Key definitions:
# KEY `related_id` (`related_id`),
# KEY `search3` (`related_id`,`opt_datetime`),
# Column types:
# `related_id` int(10) unsigned not null comment ‘?????id’
# `opt_datetime` datetime not null comment ‘??????’
# To remove this duplicate index, execute:
ALTER TABLE `grape`.`gp_operate_log` DROP INDEX `related_id`;
# ########################################################################
# grape.gp_report_advertiser_hour
# ########################################################################
# idx_line_id is a left-prefix of line_id_data_time
# Key definitions:
# KEY `idx_line_id` (`line_id`),
# KEY `line_id_data_time` (`line_id`,`data_time`),
# Column types:
# `line_id` bigint(20) not null
# `data_time` datetime not null
# To remove this duplicate index, execute:
ALTER TABLE `grape`.`gp_report_advertiser_hour` DROP INDEX `idx_line_id`;
# ########################################################################
# Summary of indexes
# ########################################################################
# Size Duplicate Indexes 48
# Total Duplicate Indexes 3
# Total Indexes 268
工具检测到gp_operate_log有重复的索引,提供以下SQL语句删除重复的索引:
ALTER TABLE `grape`.`gp_operate_log` DROP INDEX `related_id`;
explain简化显示示例:
root@ubuntu:/tmp/d3OnxmMr# mysql -hsohu.dev.chenpeng.info -P43307 -ugrapeuser -pfaf74223tr grape -e”explain SELECT a.line_id,b.dnf_source FROM gp_report_advertiser_day a INNER JOIN gp_line b ON a.line_id=b.id WHERE a.data_date=’2016-04-10′ LIMIT 100″ | pt-visual-explain
JOIN
+- Filter with WHERE
| +- Bookmark lookup
| +- Table
| | table b
| | possible_keys PRIMARY
| +- Unique index lookup
| key b->PRIMARY
| possible_keys PRIMARY
| key_len 4
| ref grape.a.line_id
| rows 1
+- Index lookup
key a->data_date
possible_keys line_id,data_date
key_len 3
ref const
rows 10722
建议继续学习:
- Mysql监控指南 (阅读:20597)
- 分享一个JQUERY颜色选择插件 (阅读:13630)
- 服务器性能测试工具推荐 (阅读:7493)
- 10个最有帮助的在线协同工具 (阅读:5582)
- 性能测试工具sysbench简介 (阅读:5555)
- 为什么我认为每个穷网站开发程序员都应该用Linux[工具篇] (阅读:5160)
- 使用PHP_UML生成代码的UML图 (阅读:4962)
- 轻量级在线原型设计工具mockingbird (阅读:4772)
- 前端开发小工具集合 (阅读:4665)
- Chrome开发者工具的小技巧 (阅读:4620)
扫一扫订阅我的微信号:IT技术博客大学习
- 作者:智足者富 来源: 陈鹏个人博客
- 标签: percona-toolkit 工具
- 发布时间:2016-04-17 17:46:45
-
[938] WordPress插件开发 -- 在插件使用 -
[119] 解决 nginx 反向代理网页首尾出现神秘字 -
[51] 如何保证一个程序在单台服务器上只有唯一实例( -
[50] ps 命令常见用法 -
[49] 用 Jquery 模拟 select -
[49] 整理了一份招PHP高级工程师的面试题 -
[49] 海量小文件存储 -
[48] find命令的一点注意事项 -
[48] Innodb分表太多或者表分区太多,会导致内 -
[47] 全站换域名时利用nginx和javascri
