In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "insert carries on the first optimistic insertion logic analysis", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "insert for the first optimistic insertion logic analysis"!
Lock inheritance may be triggered
The only check that could trigger LOCK_S is also here.
Locate the data before inserting
Undo is generated before redo generation
The logical entry is as follows:
-> row_ins_sec_index_entry_low optimistically inserts mode=BTR_MODIFY_LEAF for the first time-> whether the only key is row_ins_scan_sec_index_for_duplicate for uniqueness check-> processing of uniqueness test results-> data lookup btr_cur_search_to_nth_level-> page_cur_search_with_match_bytes-> if you just check duplicate values and skip Face logic if (dup_chk_only)-> optimistic insertion Assuming that the B + tree structure btr_cur_optimistic_insert is not modified, it is mainly identified by BTR_MODIFY_LEAF marking. Do not consider the compressed page-> calculate the length of the converted logical record (tuple) to a physical record rec_get_converted_size-> rec_get_converted_size_comp-> whether external storage page_zip_rec_needs_ext-> get the free space size of the block page_get_max_insert_size_after_reorganize remarks (1-> make a logical judgment of whether sad insertion is required Mainly due to lack of space (2 If pessimistic insertion is required, return here-> if it is the primary key, you also need to reserve some space. (3) if there is no reserved space, you will enter the pessimistic insertion process-> determine whether you need to lock and open undo btr_cur_ins_lock_and_undo. This function will also return whether lock inheritance is required as the output parameter inherit-> check whether lock lock_rec_insert_check_and_lock insertion impression lock is here-> record undo trx_undo_report_row_operation-> change row undo ptr pointer row_upd_index_entry_sys_field-> do the actual insert operation page_cur_tuple_insert-> Convert a logical record to a physical record rec_convert_dtuple_to_rec-> get the offset of each field rec_get_offsets-> actually insert page_cur_insert_rec_low-> get the actual size of the record-> find the right place to insert This step will find the appropriate location to return to insert_buf-> get the header record of the free linked list. Note that only the first record will be checked, not traversal will be done. So fragments in the block are very likely to occur, but innodb can be reorganized-> use if appropriate-> return if not appropriate-> record creation copy memcpy way to copy data to the location pointed to by insert_buf After the record is added to the block, you need to maintain all kinds of block information-> add the record to the record list-> the N_OWNER of the update row is 0 And set heap_no-> set some last modified attributes of the block, such as PAGE_DIRECTION, PAGE_N_DIRECTION, PAGE_LAST_INSERT-> update slot information It may involve changing owner record information and owner record N_OWNER information-> writing redo information page_cur_insert_rec_write_log-> returning offset for inserting records-> performing AHI maintenance btr_search_update_hash_on_insert/btr_search_update_hash_node_on_insert-> performing possible lock splitting lock_update_insert where the main judgment here is the previous output Parameter inherit-> perform CHANGE BUFFER maintenance ibuf_update_free_bits_if_full-> if you successfully modify the maximum thing ID PAGE_MAX_TRX_ID page_update_max_trx_id-> return the result
Note 1) the calculation method is
Capacity of empty pages = page size (for example, 16K)-header size (120)-footer size (8)-initialize 2 slot sizes (4'2' 2)
Actual data footprint = most big data offset of allocated data space-header size-deleted and purge space contains debris space + slot size
And then use the
Capacity of empty pages-actual data footprint = actual available space
Because there will inevitably be some fragments in the page, but innodb's page has the ability to reorganize and free up this space. Its recombination function is btr_page_reorganize_low.
Note 2) logical inclusion
If it contains debris space, then
-- if the free space is insufficient or the free space is already less than the setting BTR_CUR_PAGE_REORGANIZE_LIMIT of the recombination block (UNIV_PAGE_SIZE / 32)
-- the number of records is greater than 1
-the free space is less than the size of the inserted record
otherwise
-the free space is less than the size of the inserted record
Note 3) logical inclusion
-- leaf node
-- Primary key
-the record is more than two lines
-- remaining space-- Space of rows < page_size/16
-- split proposal proposed split
At this point, I believe you have a deeper understanding of "the first optimistic insertion logic analysis of insert". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.