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 understand the innodb page recombination space compression function

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article introduces you how to understand the innodb page reorganization space compression function, the content is very detailed, interested friends can refer to, hope to be helpful to you.

When there are too many page fragments in innodb, reorganization will be triggered. The reorganization process is completed in memory. The main functions are as follows:

Click (here) to collapse or open

Bool

Btr_page_reorganize_low

{

Buf_block_t* block = page_cur_get_block (cursor); / / get the buf_block_t location

Page_t* page = buf_block_get_frame (block); / / get the data domain pointer

Data_size1 = page_get_data_size (page); / / the space actually needed by the data does not contain debris space

Max_ins_size1 = page_get_max_insert_size_after_reorganize (page, 1); / / remaining space that can be used to store data contains debris space

/ / these two functions are not only the actual space that excludes the fragment factor, but also the actual space demand after reorganization.

# ifndef UNIV_HOTBACKUP

Temp_block = buf_block_alloc (buf_pool); / / assign a temporary block from pool

# else / *! UNIV_HOTBACKUP * /

Ut_ad (block = = back_block1)

Temp_block = back_block2

# endif / *! UNIV_HOTBACKUP * /

Temp_page = temp_block- > frame; / / points to the actual data domain pointer where the actual data is stored but is empty at this time

/ * Copy the old page to temporary space * /

Buf_frame_copy (temp_page, page); / / copy the data page pointer of the current page to temp_page for temporary storage

# ifndef UNIV_HOTBACKUP

If (! recovery) {

Btr_search_drop_page_hash_index (block)

}

# endif / *! UNIV_HOTBACKUP * /

/ * Save the cursor position. , /

Pos = page_rec_get_n_recs_before (page_cur_get_rec (cursor)); / / saves the current cursor address, which is prelocated and returns a location that will not be changed before and after the reorganization

/ * Recreate the page: note that global data on page (possible

Segment headers, next page-field, etc.) Is preserved intact * /

Page_create (block, mtr, dict_table_is_comp (index- > table), is_spatial); / / initialize this block to reconstruct all kinds of fixed information under the action of the function page_create_low. This block has been emptied and the old information is stored in temp.

/ * Copy the records from the temporary space to the recreated page

Do not copy the lock bits yet * /

Page_copy_rec_list_end_no_locks (block, temp_block, / / here temp block is the old data copied line by line into block to complete spatial reorganization

Page_get_infimum_rec (temp_page)

Index, mtr); / / copy all the lines inside the block to the newly created page. This function completes the insertion of the reorganization line and there is no debris space.

Data_size2 = page_get_data_size (page); / / the space to get the reorganized data

Max_ins_size2 = page_get_max_insert_size_after_reorganize (page, 1)

If (data_size1! = data_size2 | | max_ins_size1! = max_ins_size2) {/ / here to determine whether the valid data and the remaining space are not equal before and after the reorganization, of course, there is a problem with the data.

Ib::error ()

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

Database

Wechat

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

12
Report