如何根据表结构来计算一条记录占用的存储大小?
https://link.zhihu.com/?targe...
是否可以根据上述规则来计算?
迷茫2017-04-17 15:50:28
Thanks for the invitation. I think that indexing the table cannot be based entirely on the storage size occupied by the table structure, as it will also increase the storage size.
If you want to know the space occupied by each table in the Mysql database and the number of rows recorded in the table, you can open the information_schema database of mysql. There is a Tables table in this library. The main fields of this table are:
TABLE_SCHEMA: database name
TABLE_NAME: table name
ENGINE: storage engine used
TABLES_ROWS: number of records
DATA_LENGTH: data size
INDEX_LENGTH: index size
So to know the size of the space occupied by a table, it is equivalent to data size + index size.