统计每个DB的磁盘空间使用
mysql> select table_schema "DB name (table_schema)",
-> sum((data_length+index_length)/1024/1024/1024) AS "DB size in GB" from
-> information_schema.tables group by table_schema;
+-----------------------------+-------------------+
| DB name (table_schema) | DB size in GB |
+-----------------------------+-------------------+
| information_schema | 0.000167846679 |
| xxyyzz_coins_v3_db_00000004 | 210.166442871299 |
| xxyyzz_coins_v3_db_00000004 | 1387.163970947461 |
+-----------------------------+-------------------+
3 rows in set (0.85 sec)
du -sch /location/of_Mysql/* | sort -hr | head -n20
统计每个table的磁盘空间使用
select table_schema,table_name,
truncate(data_length/1024/1024/1024, 2) as 'data_size_in_gb',
truncate(index_length/1024/1024/1024, 2) as 'index_size_in_gb',
truncate(DATA_FREE/1024/1024/1024, 2) as 'free_space_in_gb'
from information_schema.tables where table_name = "<table_name>" and table_schema like '<db_nmae>';
Reference
- https://dev.mysql.com/doc/refman/8.0/en/information-schema-tables-table.html
- https://stackoverflow.com/questions/14714750/how-to-get-true-size-of-mysql-database/21169120#21169120
- https://dba.stackexchange.com/questions/14337/calculating-disk-space-usage-per-mysql-db
- https://stackoverflow.com/questions/6474591/how-can-you-determine-how-much-disk-space-a-particular-mysql-table-is-taking-up
FEATURED TAGS
algorithm
algorithmproblem
architecturalpattern
architecture
aws
c#
cachesystem
codis
compile
concurrentcontrol
database
dataformat
datastructure
debug
design
designpattern
distributedsystem
django
docker
domain
engineering
freebsd
git
golang
grafana
hackintosh
hadoop
hardware
hexo
http
hugo
ios
iot
java
javaee
javascript
kafka
kubernetes
linux
linuxcommand
linuxio
lock
macos
markdown
microservices
mysql
nas
network
networkprogramming
nginx
node.js
npm
oop
openwrt
operatingsystem
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software testing
spring
sql
systemdesign
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
xml
zookeeper