1> pt-index-usage:从慢查询日志中读取查询并分析它们如何使用索引。 (用来查找不常使用索引) ./pt-index-usage --help 打印报告 ./pt-index-usage /mysqldata/mysqlslowlog/slowquery.log -h192.168.226.131 -uroot -p6yhn^YHN -decology [mysql@mysql bin]$ ./pt-index-usage /mysqldata/mysqlslowlog/slowquery.log -h192.168.226.131 -uroot -p6yhn^YHN DBD::mysql::db selectall_arrayref failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/' at line 1 [for Statement "EXPLAIN SELECT IFNULL(SUM(INDEX_LENGTH),0) from information_schema.TABLES where ENGINE='InnoDB' */"] at ./pt-index-usage line 4598, <> line 1. DBD::mysql::db selectall_arrayref failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/' at line 1 [for Statement "EXPLAIN SELECT IFNULL(SUM(DATA_LENGTH),0) from information_schema.TABLES where ENGINE='InnoDB' */"] at ./pt-index-usage line 4598, <> line 2. DBD::mysql::db selectall_arrayref failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/' at line 1 [for Statement "EXPLAIN SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' */"] at ./pt-index-usage line 4598, <> line 4. ALTER TABLE `test1`.`user` DROP KEY `idx_1`; -- type:non-unique 2> pt-duplicate-key-checker检查数据库的重复索引 索引会更查询带来好处,但是过量的索引反而可能会使数据库的性能降低 ./pt-duplicate-key-checker --help 1> 表结构 [root@localhost][test1]> show index from user; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | user | 0 | PRIMARY | 1 | id | A | 1042305 | NULL | NULL | | BTREE | | | | user | 1 | idx_1 | 1 | id | A | 1042305 | NULL | NULL | | BTREE | | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 字段id有两个索引, [mysql@mysql bin]$ ./pt-duplicate-key-checker -uroot -p6yhn^YHN # ######################################################################## # test1.user # ######################################################################## # idx_1 is a duplicate of PRIMARY # Key definitions: # KEY `idx_1` (`id`) # PRIMARY KEY (`id`), # Column types: # `id` int(11) not null auto_increment # To remove this duplicate index, execute: ALTER TABLE `test1`.`user` DROP INDEX `idx_1`; # ######################################################################## # Summary of indexes # ######################################################################## # Size Duplicate Indexes 4169220 # Total Duplicate Indexes 1 # Total Indexes 34
percona-toolkit之pt-index-usage和pt-duplicate-key-checker详解
来源:这里教程网
时间:2026-03-01 14:42:42
作者:
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 双11核心系统100%上云 !阿里数据库处理峰值远超传统厂商
双11核心系统100%上云 !阿里数据库处理峰值远超传统厂商
26-03-01 - Mycat监控工具Mycat-web
Mycat监控工具Mycat-web
26-03-01 - Goldengate异构数据同步方案
Goldengate异构数据同步方案
26-03-01 - [Mysql]Mysql5.7并行复制
[Mysql]Mysql5.7并行复制
26-03-01 - Flink 在人工智能领域的应用实践
Flink 在人工智能领域的应用实践
26-03-01 - 3D视觉效果制作:如何在PPT中制作3D效果?
3D视觉效果制作:如何在PPT中制作3D效果?
26-03-01 - 大学生创业计划书PPT模板之智力成果转化平台
大学生创业计划书PPT模板之智力成果转化平台
26-03-01 - 报错install_driver(mysql) failed: Attempt to reload DBD/mysql.pm
- MySQL:show processlist Time负数的思考
MySQL:show processlist Time负数的思考
26-03-01 - 重新学习Mysql数据库2:『浅入浅出』MySQL 和 InnoDB
重新学习Mysql数据库2:『浅入浅出』MySQL 和 InnoDB
26-03-01
