Hashing algorithms in the InnoDB storage engine in MySQL

Source: Internet
Author: User

The InnoDB storage engine uses a hashing algorithm to find the dictionary, and its conflict mechanism takes the form of a linked list, and the hash function uses the division hashing method. For a buffer pool page hash table, a page page in the buffer pool has a chain pointer. It points to the same hash function value of the page. For a division hash, the value of M is slightly greater than twice times the number of buffer pool pages in prime numbers. For example: The current parameter innodb_buffer_pool_size has a size of 10M and a total of 640 16kb pages. For the buffer pool page memory hash table, need to allocate 640*2=1280 slots, but because 1280 is not prime, need to take a prime number slightly larger than 1280, should be 1399, so at startup will allocate 1399 slots of the hash table, used to hash query the page in the buffer pool

So how does the buffer pool in the InnoDB storage engine look for pages in it? Above just gives the general algorithm, how to say the search page converted into natural number?

In fact, the INNODB storage engine table space has a space_id, the user asked to find a table space should be a continuous 16KB of the page, that is, the offset Offset,innodb storage engine will space_id left 20 bits, and then add this Space_ ID and offset, which is the keyword K=space_id<<20+space_id+offset, and then by triggering the hash into each slot

Hashing algorithms in the InnoDB storage engine in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.