InnoDB supports creating compressed data pages

Source: Internet
Author: User
MySQL 5.5.x supports InnoDB data page compression. Data Page compression reduces the size of data files, reduces disk I/O, increases throughput, and increases CPU utilization at a low cost. Especially for applications with more reads and less writes

MySQL 5.5.x supports InnoDB data page compression. Data Page compression reduces the size of data files, reduces disk I/O, improves throughput, and improves CPU utilization at a low cost. Especially for applications with more reads and less writes

MySQL 5.5.x supports InnoDB data page compression, Hong Kong server leasing, and data page compression to reduce the size of data files, reduce disk I/O, increase throughput, and increase CPU utilization at a low cost. Especially for applications with more reads and less writes, it is the most effective. The same memory can store more data and ensure full "dry" memory utilization.

Its working principle is: when a user obtains data, if the compressed page is not in the Innodb_Buffer_Pool buffer pool, Hong Kong Space will be loaded from the disk, in addition, a new uncompressed 16 k Data Page is opened in the Innodb_Buffer_Pool buffer pool to decompress the loaded compressed page. To reduce disk I/O and decompress the page, there are both compressed and uncompressed pages in the buffer pool. In order to free up space for other required data pages, the buffer pool will kick out uncompressed data pages, while retaining compressed pages in the memory, uncompressed pages are not accessed for a period of time, so they are directly written to the disk. Therefore, there may be compressed and uncompressed pages in the buffer pool, or only compressed pages.

Innodb uses the least recently used (LRU) algorithm to put frequently accessed hot data into the memory. When accessing a compressed table, Innodb uses an adaptive LRU algorithm to balance the compressed pages and uncompressed pages in the memory, the purpose is to avoid spending too much time on decompression when the CPU is busy, and to avoid excessive I/O operations during decompression when the CPU is idle. Therefore, when the system is in an I/O bottleneck, this algorithm will kick out uncompressed pages, rather than compressed pages, to free up space for more pages to be injected into memory. When the system is at a CPU bottleneck, this algorithm will simultaneously kick out uncompressed pages and compressed pages, so that more memory can store hot data and reduce the overhead of decompression.

In previous versions, a data page was 16 K. You can specify the compressed pages as 1, 2, 4, and 8 K when creating a table. If the value is too small, more CPU resources will be consumed, usually set to 8 K.

Note: you must use the file format Barracuda and the independent tablespace supports data page compression.

  • When creating a table, add ROW_FORMAT = COMPRESSED KEY_BLOCK_SIZE = 8, for example:

    A stress test was conducted for 8 K and 16 K data pages. The VM memory is 1 GB and the Buffer_Pool is 600 mb.

  • Create a table with 10 million rows of records first. The size of the compressed 8 K data page is half the size of the data page without 16 K compression.

    The left image is not compressed, and the right image is compressed.

    As you can see, the requested data page is smaller than the InnoDB_Buffer_Pool buffer pool size, and the uncompressed performance is slightly better than the compressed size, because compression will cause additional CPU consumption, which is not significantly different in general.

    Next, increase the Sysbench parameter and press it again.

  • The left image is not compressed 16 K, and the right image is compressed 8 K

    As you can see, the requested data page is larger than the InnoDB_Buffer_Pool buffer pool size. The compression performance is better than that of the uncompressed one, and the throughput is also improved. The most obvious difference is that the CPU Wait/IO is much lower.

    You can choose whether to enable data page Compression Based on your business needs.

    Attached is the test for mass inserts:

    During mass insertion, Hong Kong Space was almost doubled, and the performance of 8 K data pages was lower than that of 16 k Data Pages.


    See the MySQL5.5 manual:

    This article is from the "hechun's technical column" blog. Be sure to keep this source

    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.