gpt4 book ai didi

mysql - 如何找出数据库中占用内存最大的表?

转载 作者:可可西里 更新时间:2023-11-01 06:32:20 24 4
gpt4 key购买 nike

大家好,我是数据库新手。我正在处理庞大的数据库并试图清理困惑。我想首先找到在整个数据库中占用内存最高的前十个表。由于表太多,我无法找到每个表的内存。我需要占用最大空间的前 10 或 20 个表。任何帮助将非常感激。谢谢你。

最佳答案

也许是这样的:

SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;

引用 here

关于mysql - 如何找出数据库中占用内存最大的表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9932663/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com