Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to calculate Innodb table Data free in MySQL

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report