MySQL表数据dir大于size_schema.tables的大小

时间:2014-03-26 20:21:29

标签: mysql linux

Linux机器上的MySQL 5.6中我的表数据目录的大小是否大于我从information_schema.tables查询获得的大小是否有效?

文件系统中的大小(/ data /)是11G,

以下查询返回5G

SELECT sum(ROUND(((DATA_LENGTH + INDEX_LENGTH ) / 1024 / 1024),2)) AS size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='my-table-name

我错过了什么吗?


total          | free         | data          | index_data   |
 4597.85937500 | 613.00000000 | 4089.40625000 | 508.45312500 | 

1 个答案:

答案 0 :(得分:0)

以下是我用来查找数据库大小的脚本:

SELECT 
table_schema "DB Name",  
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"  FROM 
information_schema.tables  where table_schema ='schema name' ;

运行此查询并向我们显示输出:

select (sum(data_length) + sum(INDEX_LENGTH))/ 1024 / 1024 as total, 
    sum(data_free)/ 1024 / 1024  as free ,
    sum(data_length)/ 1024 / 1024 as data, 
    sum(INDEX_LENGTH/ 1024 / 1024) as index_data 
    from information_schema.tables t
    where t.TABLE_SCHEMA = 'schema name';