監控mysql索引使用效率的指令碼
SELECT
t.table_schema AS db,
t.table_name AS tab_name,
s.index_name AS index_name,
s.column_name AS field_name,
s.seq_in_index AS seq_in_index,
s2.max_columns AS max_col,
s.cardinality AS cardinality,
t.table_rows AS table_rows,
ROUND(((s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) * 100), 2) AS sel
FROM information_schema.statistics s
INNER JOIN information_schema.tables t
ON s.table_schema = t.table_schema
AND s.table_name = t.table_name
INNER JOIN (SELECT
table_schema,
table_name,
index_name,
MAX(seq_in_index) AS max_columns
FROM information_schema.statistics
WHERE table_schema != 'mysql'
GROUP BY table_schema, table_name, index_name) AS s2
ON s.table_schema = s2.table_schema
AND s.table_name = s2.table_name
AND s.index_name = s2.index_name
WHERE t.table_schema != 'mysql'
AND t.table_rows > 100
AND s.CARDINALITY IS NOT NULL
AND (s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) < 1.00
ORDER BY sel, s.table_schema, s.table_name
LIMIT 10
t.table_schema AS db,
t.table_name AS tab_name,
s.index_name AS index_name,
s.column_name AS field_name,
s.seq_in_index AS seq_in_index,
s2.max_columns AS max_col,
s.cardinality AS cardinality,
t.table_rows AS table_rows,
ROUND(((s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) * 100), 2) AS sel
FROM information_schema.statistics s
INNER JOIN information_schema.tables t
ON s.table_schema = t.table_schema
AND s.table_name = t.table_name
INNER JOIN (SELECT
table_schema,
table_name,
index_name,
MAX(seq_in_index) AS max_columns
FROM information_schema.statistics
WHERE table_schema != 'mysql'
GROUP BY table_schema, table_name, index_name) AS s2
ON s.table_schema = s2.table_schema
AND s.table_name = s2.table_name
AND s.index_name = s2.index_name
WHERE t.table_schema != 'mysql'
AND t.table_rows > 100
AND s.CARDINALITY IS NOT NULL
AND (s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) < 1.00
ORDER BY sel, s.table_schema, s.table_name
LIMIT 10
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/133735/viewspace-732013/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql監控指令碼MySql指令碼
- mysql 的一個監控指令碼,監控heartbeatMySql指令碼
- mysql mon 的一個監控指令碼,監控heartbeatMySql指令碼
- 指令碼監控MySQL伺服器指令碼MySql伺服器
- ORACLE 監控索引的使用Oracle索引
- python監控mysql主從指令碼PythonMySql指令碼
- 監控指令碼指令碼
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- oracle空間使用監控指令碼Oracle指令碼
- 監控磁碟使用率的shell指令碼指令碼
- shell指令碼:監控MySQL服務是否正常指令碼MySql
- Shell指令碼監控MySQL主從狀態指令碼MySql
- DBA監控指令碼指令碼
- session指令碼監控Session指令碼
- 埠監控指令碼指令碼
- oracle 監控指令碼Oracle指令碼
- listener監聽監控指令碼指令碼
- 監控使用高cpu的sql語句指令碼SQL指令碼
- shell指令碼:監控MySQL服務是否正常薦指令碼MySql
- 如何監控oracle的索引是否使用Oracle索引
- Oracle 監控索引的使用率Oracle索引
- 監控Oracle索引的使用情況Oracle索引
- ogg監控指令碼指令碼
- stap監控IO指令碼指令碼
- 【shell】磁碟監控指令碼指令碼
- 索引監控-查詢從未被使用過的索引索引
- 使用nrpe監控Goldengate程式指令碼Go指令碼
- 監控系統使用情況shell指令碼指令碼
- oracle使用監控指令碼_ck_tablespace.shOracle指令碼
- systemtap的網路監控指令碼指令碼
- 監控Oracle索引是否被使用?Oracle索引
- Oracle索引的監控Oracle索引
- PostgreSQL之鎖監控指令碼SQL指令碼
- Oracle DBA常用監控指令碼Oracle指令碼
- memcached程式埠監控指令碼指令碼
- Nagios 監控ESXI指令碼iOS指令碼
- 監控cpu與memory指令碼指令碼
- 資料庫監控指令碼資料庫指令碼