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 focuses on "what are the new features in MySQL5.7", friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the new features in MySQL5.7.
1. Introduction
In mysql5.7, a type FIL_PAGE_COMPRESSED has been added to the innodb page structure to complete the Transparent page compression feature
2. Description
1) the compressed content includes: all data except FIL_PAGE_DATA, including tail2) the compressed content + FIL_PAGE_DATA will be aligned with block_size and the holes will be cleared 0. It means that compressing 16K to 9K also requires 12KB data, so setting the block_size smaller will benefit from such a scenario and reduce space waste. 3) FIL_PAGE_VERSION content storage 1: which compression algorithm: ZLIB, LZ4FIL_PAGE_ORIGINAL_TYPE_V1: original page type V1 refers to FIL_PAGE_ORIGINAL_SIZE_V1: original page needs to be compressed content size FIL_PAGE_COMPRESS_SIZE_V1: content compressed size 4) currently supports two compression algorithms: zlib and lz4, which can be easily extended. 5) Compression is only when the disk is persisted, and the pages in memory are still original.
3. Usage
Table definition: you can define a compressed table through CREATE TABLE and ALTER TABLE: create table T1 (I int,b blob) compression='zlib'; can also select compression='lz4' to specify the lz4 compression algorithm. Note that the ALTER of the compression attribute takes effect immediately. After the ALTER COMPRESSION attribute operation, you need to do a table rebuild, such as optimize table operation, to punch hole the existing data. The compression attribute is stored in the frm file, storing the string length in 2 bytes, followed by the compression attribute definition string, which is also a risk point for operating system degradation.
4. Code analysis
Click (here) to collapse or open
Static
Byte*
Os_file_compress_page (
Compression compression
Ulint block_size,// file system block size. Usually 4K
Byte* src,// needs a pointer to compress the page
Ulint src_len,// page size
After byte* dst,// is compressed, it is saved to the target
Ulint* dst_len) / / compress memory length
{
Ulint len = 0
Ulint compression_level = page_zip_level
Ulint page_type = mach_read_from_2 (src + FIL_PAGE_TYPE)
/ / if you want to save space, the page size is at least twice the size of the file system block. Compressed pages do not include R-tree pages
If (page_type = = FIL_PAGE_RTREE
| | block_size = = ULINT_UNDEFINED |
| | compression.m_type = = Compression::NONE |
| | src_len < block_size * 2) {
* dst_len = src_len
Return (src)
}
/ * Must compress to = out_len) {
* dst_len = src_len
Return (src)
}
Break
Default:
* dst_len = src_len
Return (src)
}
/ * Copy the header as is. , /
Memmove (dst, src, FIL_PAGE_DATA)
/ * Add compression control information. Required for decompressing. , /
Mach_write_to_2 (dst + FIL_PAGE_TYPE, FIL_PAGE_COMPRESSED)
Mach_write_to_1 (dst + FIL_PAGE_VERSION, 1)
Mach_write_to_1 (dst + FIL_PAGE_ALGORITHM_V1, compression.m_type)
Mach_write_to_2 (dst + FIL_PAGE_ORIGINAL_TYPE_V1, page_type)
Mach_write_to_2 (dst + FIL_PAGE_ORIGINAL_SIZE_V1, content_len)
Mach_write_to_2 (dst + FIL_PAGE_COMPRESS_SIZE_V1, len)
/ * Round to the next full block size * /
Len + = FIL_PAGE_DATA
* dst_len = ut_calc_align (len, block_size)
/ * Clear out the unused portion of the page. , /
If (len% block_size) {
Memset (dst + len, 0x0, block_size-(len% block_size))
}
Return (dst)
}
At this point, I believe you have a deeper understanding of "what are the new features in MySQL5.7". 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.