[英]How to get the storage space of a table in the MariaDB MyRocks storage engine
I'm trying to get the space that a table using the MyRocks storage engine takes on disk and I'm getting inconsistent results between what I expect, a query on information_schema
and the size as reported by the OS. 我正在尝试获取使用MyRocks存储引擎的表占用磁盘的空间,并且我在期望的内容,对
information_schema
的查询和操作系统报告的大小之间得到不一致的结果。
To get the size as reported by MariaDB, I'm using the following select statement: 要获得MariaDB报告的大小,我使用以下select语句:
select table_name 'Table Name',
(data_length+index_length)/power(1024,3) 'Table Size in GB'
from information_schema.tables where table_schema="MyTableName";
Which returns a really small number for what I'm doing, to the point where I'm doubtful that it's reporting the actual size (0.4GB for 4 000 000 rows with a lot of text). 对于我正在做的事情,它返回一个非常小的数字,我怀疑它是否报告实际大小(对于4 000 000行有大量文本的0.4GB)。
If I run the command du -h /var/lib/mysql/#rocksdb/
, I'm getting a disk size of 2.4GB, which is a bit more than what I would expect. 如果我运行命令
du -h /var/lib/mysql/#rocksdb/
,我的磁盘大小为2.4GB,这比我预期的要多一些。 However, if I understand correctly, MyRocks compacts data as data is inserted, so it's possible that the disk space reported by the du
command is unrepresentative of the actual table size. 但是,如果我理解正确,MyRocks会在插入数据时压缩数据,因此
du
命令报告的磁盘空间可能无法代表实际的表大小。
So, is there a reliable method to get the size of a table? 那么,是否有一种可靠的方法来获得表的大小? Am I already using the correct way to get the table size?
我是否已经使用正确的方法来获取表格大小?
It looks like you need to use POWER(1024,3)
instead of POWER(2014,3)
assuming that storage engine is MyISAM: 假设存储引擎是MyISAM,您似乎需要使用
POWER(1024,3)
而不是POWER(2014,3)
:
select table_name AS `Table Name`,
(data_length+index_length)/power(1024,3) AS `Table Size in GB`
from information_schema.tables
where table_schema='MyTableName';
And calculation: 并计算:
(data_length+index_length)/(2014*2014*2014) = 0.4
=>
(data_length+index_length) = 3267671497,6
3267671497,6/(1024*1024*1024) = 3.04GB
For MyISAM, DATA_LENGTH is the length of the data file, in bytes .
对于MyISAM,DATA_LENGTH是数据文件的长度, 以字节为单位 。
For InnoDB, DATA_LENGTH is the approximate amount of memory allocated for the clustered index, in bytes.
对于InnoDB,DATA_LENGTH是为聚簇索引分配的大致内存量, 以字节为单位。 Specifically, it is the clustered index size, in pages, multiplied by the InnoDB page size.
具体来说,它是聚集索引大小(以页为单位)乘以InnoDB页面大小。 )
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.