InnoDB支持创建压缩数据页
从MySQL5.5.X版本开始,支持InnoDB数据页压缩,数据页的压缩使数据文件体积变小,减少磁盘I/O,提高吞吐量,小成本的提高CPU利用率。尤其是对读多写少的应用,最
从MySQL5.5.X版本开始,支持InnoDB数据页压缩,香港服务器租用,数据页的压缩使数据文件体积变小,减少磁盘I/O,提高吞吐量,小成本的提高CPU利用率。尤其是对读多写少的应用,最为有效,同样的内存可以存储更多的数据,充分的“榨干”内存利用率。
它的工作原理是:当用户获取数据时,如果压缩的页没有在Innodb_Buffer_Pool缓冲池里,香港空间,那么会从磁盘加载进去,并且在Innodb_Buffer_Pool缓冲池里开辟一个新的未压缩16K的数据页来解压缩加载进来的压缩页,为了减少磁盘I/O以及对页的解压,在缓冲池里同时存在压缩和未压缩的页。为了给其他需要的数据页腾出空间,缓冲池里会把未压缩的数据页踢出去,而保留压缩的页在内存,未压缩的页在一段时间内没有被访问,那么会直接写入磁盘里,因此缓冲池里中可能有压缩和未压缩的页,或者只有压缩页。
Innodb采用最近最少使用(LRU)算法,将经常被访问的热数据放入内存里。当访问一个压缩表时,Innodb使用一个自适应的LRU算法来实现内存中压缩页和未压缩页一个适当的平衡,其目的是为了避免当CPU繁忙时花费太多的时间用在解压缩上,也为了避免当CPU空闲时做过多的I/O操作在解压缩上。所以,当系统处于I/O瓶颈时,这个算法会踢出未压缩的页,而不是压缩的页,为了让更多的页注入内存腾出空间。当系统处于CPU瓶颈时,这个算法会同时踢出未压缩的页和压缩的页,让更多的内存存放热数据,减少解压缩带来的开销。
在以前的版本,一个数据页是16K,现在可以在建表时指定压缩的页是1,2,4,8K,设置过小,会导致消耗更多的CPU,通常设置为8K。
注:必须采用文件格式Barracuda,且独立表空间才支持数据页压缩。
在建表的时候加入ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8即可,如:
针对数据页8K和16K,进行了一次压力测试,虚拟机内存1G,Buffer_Pool为600M。
先创建1千万行记录的表,经过压缩的8K数据页的表要比未压缩16K的数据页体积小一半。
左图为未压缩,右图为压缩
从图中所看,被请求的数据页小于InnoDB_Buffer_Pool缓冲池大小,未压缩的性能要稍好于压缩过的,因为压缩会带来额外的CPU消耗,总体上差异不大。
下面把Sysbench参数调大,再压一次
左图为未压缩16K,右图为压缩8K
从图中所看,被请求的数据页大于InnoDB_Buffer_Pool缓冲池大小,压缩的性能要好于未压缩过的,吞吐量也提高,最为明显CPU Wait/IO降低很多。
根据以上两种情况,你可根据自身的业务情况,来选择是否开启数据页压缩功能。
另附上大批量插入时的测试:
在大批量插入的时候,香港空间,几乎慢了1倍,8K数据页性能要比16K数据页性能有所下降。
参见MySQL5.5手册:
本文出自 “贺春旸的技术专栏” 博客,请务必保留此出处

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

With memory compression on Windows 11, your device will choke even with a limited amount of RAM. In this article, we will show you how to enable or disable memory compression on Windows 11. What is memory compression? Memory compression is a feature that compresses data before writing it to RAM, thus providing more storage space on it. Of course, more data stored in physical memory translates into faster system operation and better overall performance. This feature is enabled by default in Windows 11, but if it's somehow not active, you can disable or re-enable it. How to enable memory compression in Windows 11? Click the search bar, type powershell, and click

I found that the compressed package downloaded from a download website will be larger than the original compressed package after decompression. The difference is tens of Kb for a small one and several dozen Mb for a large one. If it is uploaded to a cloud disk or paid space, it does not matter if the file is small. , if there are many files, the storage cost will be greatly increased. I studied it specifically and can learn from it if necessary. Compression level: 9-Extreme compression Dictionary size: 256 or 384, the more compressed the dictionary, the slower it is. The compression rate difference is larger before 256MB, and there is no difference in compression rate after 384MB. Word size: maximum 273 Parameters: f=BCJ2, test and add parameter compression rate will be higher

How to use Nginx to compress and decompress HTTP requests Nginx is a high-performance web server and reverse proxy server that is powerful and flexible. When processing HTTP requests, you can use the gzip and gunzip modules provided by Nginx to compress and decompress the requests to reduce the amount of data transmission and improve the request response speed. This article will introduce the specific steps of how to use Nginx to compress and decompress HTTP requests, and provide corresponding code examples. Configure gzip module

Many friends need to record screens for office work or transfer files, but sometimes the problem of files that are too large causes a lot of trouble. The following is a solution to the problem of files that are too large, let’s take a look. What to do if the win10 screen recording file is too large: 1. Download the software Format Factory to compress the file. Download address >> 2. Enter the main page and click the "Video-MP4" option. 3. Click "Add File" on the conversion format page and select the MP4 file to be compressed. 4. Click "Output Configuration" on the page to compress the file according to the output quality. 5. Select "Low Quality and Size" from the drop-down configuration list and click "OK". 6. Click "OK" to complete the import of video files. 7. Click "Start" to start the conversion. 8. After completion, you can

Golang's method of achieving image quality compression. With the rapid development of the Internet, images have become one of the important media for people to communicate and transmit information online. However, high-resolution images not only take up a lot of storage space, but also increase the loading time during network transmission, which has a certain impact on the user experience. Therefore, in practical applications, image compression is a very meaningful task. This article will introduce how to use Golang to compress image quality. First, we need to import Gola

Common problems of too-large log files on Linux servers and their solutions. With the rapid development of the Internet and the widespread use of servers, it has become a common problem that server log files are getting larger and larger. A large amount of log data not only takes up disk space, but may also affect the performance and operational stability of the server. This article will discuss the common problem of too large log files on Linux servers and provide some solutions. 1. Common log files on Linux servers. Common log files include system logs, application logs, We

Office workers use wps software very frequently at work. Sometimes they input multiple files a day and then send them to the leader or to a designated location. So how does wps software compress a folder and package it for sending? The editor below will teach you. This operation step. First, organize the files and folders you want to send into the same folder. If you have a lot of files, it's a good idea to name each file so it's easier to identify when sending. Second step, this time click on this large folder and then right-click. Select "Add to archive". Step 3: At this time, the software will automatically help us package our files. Select "Compress to XX.zip". This zip is the packaging format, and then click Compress Now.

Packaging and compression are commonly used operations in Linux, but many users tend to confuse the two concepts. This article will discuss the differences between packaging and compression in Linux systems in detail, and use specific code examples to help readers better understand. First, we need to clarify the difference between packaging and compression. Packaging is the combination of multiple files or directories into a single file, often used to organize, archive, or transfer files. Compression is to compress one or more files through an algorithm to reduce the size of the file, save storage space or speed up the transmission.
