mysqlidxchk查看mysql未使用索引官方文档
2011-09-15 19:15
435 查看
mysqlidxchk Documentation
mysqlidxchk (MySQL Index Checker) checks MySQL databases/tables for unused indexes. To accomplish this task, mysqlidxchk requires one or more log files which can be any number and combination of slow, general, and "raw" log files. mysqlidxchk then compares the indexes used by the queries from the log files to all existing indexes in the database schema and reports which indexes in the database schema are not used.The completeness of mysqlidxchk's unused index report is related to the representativeness of the queries from the log files for the entire database schema. For example, if no queries use database x, then mysqlidxchk may report that all indexes for all tables in database x are unused. These details are discussed further in the Guide To Using mysqlidxchk.
A Note About Options
Technically, command line options are in the form --option, but -option works too. All options can be abbreviated if the abbreviation is unique. For example, option --host can be abbreviated --ho but not --h because --h is ambiguous: it could mean --host or --help.Options
--user USER --password --host ADDRESS --port PORT --socket SOCKET --no-mycnf --help (-?) | These options mimic most standard applications. --password can take the password on the command line like "--password FOO". Using --password alone without giving a password on the command line causes mysqlidxchk to prompt for a password. --no-mycnf makes mysqlidxchk not read ~/.my.cnf which it does by default otherwise. --user and --password always override values from ~/.my.cnf. |
--debug | Using --debug causes mysqlidxchk to print a lot of extra debugging information about what it is doing internally. In release versions of mysqlidxchk, debugging information does not include log parsing information. For more information about release verses debug versions of mysqlidxchk, read mysqlidxchk Bugs & Problems. |
--general (-g) LOG --slow (-s) LOG --raw (-r) LOG | mysqlidxchk can read and combine multiple MySQL slow and general logs, as well as "raw" logs. Raw logs are simply files with ;\n (semi-colon new-line) terminated SQL statements. At least one log file must be given. Multiple log files can be specified like: "-g log1,log2,log3 -s slow_queries.log". By default, only SELECT, UPDATE and USE db statements are read; all other statements are discarded. General logs and raw logs are more reliable than slow logs because general logs always contain an equivalent "USE db" statement, and a "USE db" statement can and should be added to raw logs. Slow logs, however, may or may not contain a "USE db." If not, mysqlidxchk tries to discover which database a query belongs to. The database discovery process is discussed in the Guide To Using mysqlidxchk. |
--grep P | grep and save only those statements which match Perl regex pattern P. |
--databases (-D) D | By default mysqlidxchk uses and reports on every index in every table in every database. However, there are times when you may wish to only consider a limited number of databases. The --databases option causes mysqlidxchk to only report on the given databases D (where D is a comma-separated list of database names without any spaces). Queries which use databases not given in D are silently discarded. |
--show-used (-su) | By default mysqlidxchk only reports unused indexes. --show-used causes mysqlidxchk to show all indexes both unused and used. Used indexes have a number in parenthesis beside them, like (7), where '7' is the number of unique queries that use that index. |
--ignore-update (-iu) | mysqlidxchk transforms UPDATE statements into SELECT statements by dropping the SET clause and adding "SELECT * FROM". For example, "UPDATE table SET col = 1 WHERE something IS NULL" becomes "SELECT * FROM table WHERE something IS NULL". --ignore-update causes mysqlidxchk to silently discard all UPDATE statements. |
--no-db-discovery (-ndd) | If a query does not have a database, mysqlidxchk attempts to discover the query's appropriate database. --no-db-discovery prevents mysqlidxchk from this attempt. Queries without databases will not be EXPLAINed. The database discovery process is discussed in the Guide To Using mysqlidxchk. |
--no-discovery-report (-ndr) | While attempting to discover databases for queries without databases, mysqlidxchk prints extra information about its successes and failures. --no-discovery-report suppress this extra information. Database discovery will still be attempted with this option. |
What To Do About Bug and Errors
If mysqlidxchk will not work for you, please read the brief guide to submitting bug and problem reports : mysqlidxchk Bugs & Problems本文出自 “openpy” 博客,请务必保留此出处http://openpy.blog.51cto.com/2798268/1572330相关文章推荐
- 官方mysql中查看索引是否被使用到
- MySQL之Handler_read_*查看索引使用情况
- MySQL索引:查看、创建、删除、使用技巧
- MySQL5.7官方文档翻译: 全文索引,自然语言搜索模式
- MySQL的Explain关键字查看是否使用索引
- MySQL官方文档14.8.2.2节 — InnoDB索引的物理结构译文
- MySQL中explain的用法及查看使用了哪些索引!
- MySQL的Explain关键字查看是否使用索引
- Mysql查看索引使用情况
- 如何使用mysql 命令行 查看mysql表大小、数据大小、索引大小
- mysql如何查看未使用的索引
- 索引-mysql索引创建、查看、删除及使用示例
- 查看mysql表大小索引大小以及临时表使用技巧,分区与分表区别
- 【GROUP_CONCAT】使用之MySQL官方文档说明
- MySQL中文全文索引插件 mysqlcft 1.0.0 安装使用文档[原创]
- mysql查看是否使用索引
- MySQL的Explain关键字查看是否使用索引
- 【CONCAT】使用之MySQL官方文档说明
- 使用和管理(查看,创建,删除)MySQL索引
- mysql 查看索引使用情况