The MySQL database looks at the size and number of records occupied by the data table.

MySQLYou can open MySQL’s information_schema database if each table in the database takes up space and the number of rows it records. There is a TABLES table in the library. The main fields of the table are:

TABLE_SCHEMA : Database nameTABLE_NAME: table nameENGINE: storage engine usedTABLES_ROWS: record numberDATA_LENGTH: data sizeINDEX_LENGTH: index size

The size of the space occupied by a table is equivalent to the size of the data and the size of the index.
Examples:

1、View all the table sizes of the enrolment_db Library:

select table_name,table_rows from tables where TABLE_SCHEMA = 'enrolment_db' order by table_rows desc; 

2、View all table sizes and index lengths of the enrolment_db Library:

SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM information_schema.TABLES WHERE TABLE_SCHEMA='enrolment_db' order by TABLE_ROWS DESC;

3、Statistics of all records in enrolment_db table:

SELECT sum(TABLE_ROWS) as heji FROM information_schema.TABLES WHERE TABLE_SCHEMA='enrolment_db';

Note: the table_rows row count under the InnoDB engine is only a rough estimate.

Leave a Reply

Your email address will not be published. Required fields are marked *