惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
V
Visual Studio Blog
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
C
Check Point Blog
D
Docker
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
博客园 - 叶小钗
博客园 - 聂微东
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
腾讯CDC
S
SegmentFault 最新的问题
博客园 - 【当耐特】

裴先生笔记

[通胀十年]“消费驱动、自由化”转向“安全驱动、再工业化“ - 裴先生笔记 Jenkins + Docker 全流程实战(前后端构建 & 常见问题) 轻量级多节点系统监控方案实战:Node Exporter + Prometheus + Grafana & 替代方案 如何查询 Hive表 stored as 类型 [通胀十年]超级债务危机 - 裴先生笔记
查看 MYSQL 库大小、表大小、索引大小 - 裴先生笔记
2025-01-16 · via 裴先生笔记

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

SELECT temp.`Table Name`                  AS tableName,
       CONCAT(temp.`Number of Rows`, 'M') AS NumberofRows,
       CONCAT(temp.`Data Size`, 'G')      AS DataSize,
       CONCAT(temp.`Index Size`, 'G')     AS IndexSize,
       CONCAT(temp.Total, 'G')            AS Total
FROM (SELECT CONCAT(table_schema, '.', table_name)                         AS 'Table Name',
             ROUND(table_rows / 1000000, 4)                                AS 'Number of Rows',
             ROUND(data_length / (1024 * 1024 * 1024), 4)                  AS 'Data Size',
             ROUND(index_length / (1024 * 1024 * 1024), 4)                 AS 'Index Size',
             ROUND((data_length + index_length) / (1024 * 1024 * 1024), 4) AS 'Total'
      FROM information_schema.TABLES
      WHERE table_schema LIKE 'YOUR_DATABASE_NAME') temp
ORDER BY temp.Total DESC

查询结果如下:

tableName NumberofRows DataSize IndexSize Total
umami_2.website_event 0.0406M 0.0142G 0.0662G 0.0805G
umami_2.session 0.0185M 0.0034G 0.0368G 0.0403G
umami_2.team_user 0.0000M 0.0000G 0.0000G 0.0001G
umami_2.team 0.0000M 0.0000G 0.0000G 0.0001G
umami_2.session_data 0.0000M 0.0000G 0.0000G 0.0001G
umami_2.report 0.0000M 0.0000G 0.0001G 0.0001G
umami_2.event_data 0.0000M 0.0000G 0.0001G 0.0001G
umami_2.website 0.0000M 0.0000G 0.0001G 0.0001G
umami_2._prisma_migrations 0.0000M 0.0000G 0.0000G 0.0000G
umami_2.user 0.0000M 0.0000G 0.0000G 0.0000G