关于mysql:一条Sql查询MySql数据存储状况

36次阅读

共计 514 个字符,预计需要花费 2 分钟才能阅读完成。

0x00. 小声逼逼

DBA 和运维的同学都晓得 Mysql 的性能问题,每次去客户调研零碎现状都会看下数据状况,个别我会先查看下存储、索引和数据条数。

0x01. 上面是 Sql

SELECT ISS.SCHEMA_NAME AS 'SCHEMA_NAME',
ITS.TABLE_NAME AS 'TABLE_NAME',
(ITS.DATA_LENGTH / 1024 / 1024) AS 'DATA (MB)',
(ITS.INDEX_LENGTH / 1024 / 1024) AS 'INDEX (MB)',
((ITS.DATA_LENGTH + ITS.INDEX_LENGTH) / 1024 / 1024) AS 'DATA + INDEX (MB)',
ITS.TABLE_ROWS AS 'TOTAL_ROW'
FROM information_schema.`TABLES` ITS
RIGHT JOIN
information_schema.SCHEMATA ISS ON ITS.TABLE_SCHEMA = ISS.SCHEMA_NAME
WHERE ISS.SCHEMA_NAME = ${DATABASE_NAME}
ORDER BY 4 DESC, ISS.SCHEMA_NAME, ITS.TABLE_NAME;

over

正文完
 0