Get the App
SLTechnology News&Howtos  ›  Database  › 

How to calculate Innodb table Data free in MySQL

Shulou Source: shulou.com Published: 2022-05-31 15:54:59 10月02日 Update

The purpose of this article is to share with you how to calculate the Data free of the Innodb table in MySQL. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

About the size of a free extent.

ST_FIELD_INFO tables_fields_info [] = {... {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE},...} tables_fields_info [12] is Data_freeST_SCHEMA_TABLE schema_tables [] = {... {"TABLES", tables_fields_info, create_schema_table Get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0, OPTIMIZE_I_S_TABLE},...} fill the get_schema_tables_record function with a sentence table- > field [12]-> store ((longlong) file- > stats.delete_length, TRUE) It's actually file- > stats.delete_length.

Where file- > stats.delete_length is called to take the value

Ha_innobase::info_low contains avail_space = fsp_get_available_space_in_free_extents (ib_table- > space); stats.delete_length = avail_space * 1024; total page size if (size_in_header) of ulint size_in_header = space- > size_in_header;//

< FSP_EXTENT_SIZE) { //碎片页 直接返回0 return(0); /* TODO: count free frag pages and return a value based on that */ } /* Below we play safe when counting free extents above the free limit: some of them will contain extent descriptor pages, and therefore will not be free extents */ ut_ad(size_in_header >

= space- > free_limit); ulint n_free_up = (size_in_header-space- > free_limit) / FSP_EXTENT_SIZE; / / (Total page size-initialized size) / EXTENT SIZE page_size_t page_size (space- > flags); if (n_free_up > 0) {nasty freeway update- N_free_up-= n_free_up / (page_size.physical () / FSP_EXTENT_SIZE); / / minus extent management block?} / * We reserve 1 extent + 0.5% of the space size to undo logs and 1 extent + 0.5% to cleaning operations NOTE: this source code is duplicated in the function above! * / ulint reserve = 2 + ((size_in_header / FSP_EXTENT_SIZE) * 2) / 200; ulint n_free = space- > free_len + nasty freeway up; if (reserve > n_free) {return (0);} return (static_cast (n_free-reserve) * FSP_EXTENT_SIZE * (page_size.physical () / 1024)) } Thank you for reading! This is the end of the article on "how to calculate the Data free of the Innodb table in MySQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Size content that is more articles pages good practical function actual article way look knowledge free reference help related management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno vpn Redmi Shulou Information