当前位置:网站首页>I didn't expect that the index occupies several times as much space as the data MySQL queries the space occupied by each table in the database, and the space occupied by data and indexes. It is used i
I didn't expect that the index occupies several times as much space as the data MySQL queries the space occupied by each table in the database, and the space occupied by data and indexes. It is used i
2022-06-13 02:06:00 【Python's path to becoming a God】
Paste a picture first !
First step ,“ Very important ”
stay mysql in , There is a library built in at the beginning of creation information_schema
, This library contains database related information , The space occupied by querying data is to use the library , So first enter this library
-- First of all to enter mysql System libraries
use information_schema;
The second step : Inquire about
Use sum(DATA_LENGTH/1024/1024)
Statistical occupancy MB size , It's divided into two parts , One is DATA_LENGTH
— data 、INDEX_LENGTH
— Indexes .
as follows :
-- Querying all data in the database takes up space
SELECT
concat( round( sum( DATA_LENGTH / 1024 / 1024 ), 2 ), 'MB' ) AS DATA
FROM
TABLES;
-- The query database Of Designated table Data takes up space
SELECT
concat( round( sum( data_length / 1024 / 1024 ), 2 ), 'MB' ) AS DATA
FROM
TABLES
WHERE
table_schema = '{your database}'
AND table_name = '{your table name}';
-- The query database Of Designated table Index takes up space
SELECT
concat( round( sum( index_length / 1024 / 1024 ), 2 ), 'MB' ) AS DATA
FROM
TABLES
WHERE
table_schema = '{your database}'
AND table_name = '{your table name}';
The third step : Use immediately
Two polished sql, You can directly and clearly query library and The size of the table . Just change the parameters {your databse}
that will do
PS: The first step must be performed first
-- Query the sum of all tables in the library , Itemized
select
table_schema as ' database ',
sum(table_rows) as ' Record number ',
sum(truncate(data_length/1024/1024, 2)) as ' Data capacity (MB)',
sum(truncate(index_length/1024/1024, 2)) as ' Index capacity (MB)'
from information_schema.tables
where table_schema='{your database}';
-- The space occupied by each table in the Query Library , Itemized
select
table_schema as ' database ',
table_name as ' Table name ',
table_rows as ' Record number ',
truncate(data_length/1024/1024, 2) as ' Data capacity (MB)',
truncate(index_length/1024/1024, 2) as ' Index capacity (MB)'
from information_schema.tables
where table_schema='{your database}'
order by data_length desc, index_length desc;
边栏推荐
- 记录:如何解决MultipartFile类的transferTo()上传图片报“系统找不到指定的路径“问题【亲测有效】
- Mac使用Docker安装Oracle
- SQL server deletes all tables and all stored procedures in the database
- The scientific innovation board successfully held the meeting, and the IPO of Kuangshi technology ushered in the dawn
- Sensorless / inductive manufacturing of brushless motor drive board based on stm32
- Server installation jupyterab and remote login configuration
- 传感器:MQ-5燃气模块测量燃气值(底部附代码)
- Alertwindowmanager pop up prompt window help (Part 1)
- Application and examples of C language structure
- uniapp 预览功能
猜你喜欢
Ruixing coffee 2022, extricating itself from difficulties and ushering in a smooth path
华为设备配置CE双归属
Use mediapipe+opencv to make a simple virtual keyboard
[the third day of actual combat of smart lock project based on stm32f401ret6 in 10 days] communication foundation and understanding serial port
Viewing the ambition of Xiaodu technology from intelligent giant screen TV v86
dfs与bfs解决宝岛探险
General IP address, account and password of mobile IPv6 optical cat login, and mobile optical cat is in bridging mode
微服务开发环境搭建
Day 1 of the 10 day smart lock project (understand the SCM stm32f401ret6 and C language foundation)
Calculation of accuracy, recall rate, F1 value and accuracy rate of pytorch prediction results (simple implementation)
随机推荐
JSON and protobuf Any interchange
Calculation of accuracy, recall rate, F1 value and accuracy rate of pytorch prediction results (simple implementation)
华为设备配置双反射器优化虚拟专用网骨干层
[learning notes] xr872 GUI littlevgl 8.0 migration (display part)
Examples of using the chromium base library
The new wild prospect of JD instant retailing from the perspective of "hour shopping"
js获取元素
Huawei equipment is configured with CE dual attribution
Interruption of 51 single chip microcomputer learning notes (external interruption, timer interruption, interrupt nesting)
Rsync transport exclusion directory
What is Google plus large text ads? How to use it?
JS get element
The method of drawing rounded panel with Delphi
Swiper horizontal rotation grid
微服务开发环境搭建
Anti crawling strategy (IP proxy, setting random sleep time, bilbili video information crawling, obtaining real URLs, processing special characters, processing timestamp, and multithreading)
[the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] (lighting with library function and register respectively)
C language conditional compilation routine
Application circuit and understanding of BAT54C as power supply protection
Leetcode daily question - 890 Find and replace mode