Home > database >  Database query table size and the real physical file compared to the size of the gap is bigger
Database query table size and the real physical file compared to the size of the gap is bigger

Time:09-19

Database query table size and the real physical file compared the size of the gap between

# # database query the table size is 1.9 G
Mysql> Select
- & gt; Table_schema as' db '
- & gt; Table_name as' table ',
- & gt; Table_rows as' count ',
- & gt; Truncate (data_length/1024/1024, 2) the as' data (MB) ',
- & gt; Truncate (index_length/1024/1024, 2) the as' index (MB) '
- & gt; The from information_schema. Tables
- & gt; The order by data_length desc, index_length desc;
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- - +
| of the | table | count | data (MB) | index (MB) |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- - +
| openapi | log_r_esb | 5312774 | | | 0.00 1957.00


# # # file system the directory query table file size is 5 g,
[root @ poipredis03 openapi] # du - s * | sort - nr
5971972 log_r_esb. Ibd


Excuse me, how to explain?

CodePudding user response:

Fragments may be because the table, delete the data, the OS file will not shrink, but the size of the table will be smaller, so it caused the OS file with the fragmentation of space,
The official explanation for date_length:
? DATA_LENGTH 
For the MyISAM, DATA_LENGTH is the length of the data file, in bytes.
For InnoDB, DATA_LENGTH is the approximate amount of memory allocated For the clustered index,
In bytes. Specifically, it is the clustered index, the size, in pages, multiplied by the InnoDB page size.

CodePudding user response:

Should be the innodb engine,
Mysql> The select table_catalog
- & gt; , table_schema
- & gt; And table_name
- & gt; The engine
- & gt; The from information_schema. Tables
- & gt; Where table_schema='openapi and table_name=' log_r_esb ';
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
| table_catalog | table_schema | table_name | engine |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --
| def | openapi | log_r_esb | InnoDB |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- + + -- -- -- -- -- -- -- --


Fragments may be because the table, delete the data, the OS file will not shrink, but the size of the table will be smaller, so it caused the OS file with the fragmentation of space,
Thank you -"

CodePudding user response:

Regularly use opotimize table to optimize table, when using table lock
  • Related