Mesmo depois de executar a compactação, você ainda pode não obter o desempenho que está procurando. Por quê?
O InnoDB tem o Buffer Pool para carregar páginas de dados e páginas de índice lidas para atender consultas. Ao ler uma tabela e seus índices pela primeira vez, a página compactada deve ser descompactada. Na verdade, você pode ter o dobro de dados no buffer pool como resultado disso.
Observe como esse é o caso da Documentação do MySQL
Compression and the InnoDB Buffer Pool
In a compressed InnoDB table, every compressed page (whether 1K, 2K, 4K or 8K) corresponds to an uncompressed page of 16K bytes. To access the data in a page, InnoDB reads the compressed page from disk if it is not already in the buffer pool, then uncompresses the page to its original 16K byte form. This section describes how InnoDB manages the buffer pool with respect to pages of compressed tables.
To minimize I/O and to reduce the need to uncompress a page, at times the buffer pool contains both the compressed and uncompressed form of a database page. To make room for other required database pages, InnoDB may “evict” from the buffer pool an uncompressed page, while leaving the compressed page in memory. Or, if a page has not been accessed in a while, the compressed form of the page may be written to disk, to free space for other data. Thus, at any given time, the buffer pool may contain both the compressed and uncompressed forms of the page, or only the compressed form of the page, or neither.
InnoDB keeps track of which pages to keep in memory and which to evict using a least-recently-used (LRU) list, so that “hot” or frequently accessed data tends to stay in memory. When compressed tables are accessed, InnoDB uses an adaptive LRU algorithm to achieve an appropriate balance of compressed and uncompressed pages in memory. This adaptive algorithm is sensitive to whether the system is running in an I/O-bound or CPU-bound manner. The goal is to avoid spending too much processing time uncompressing pages when the CPU is busy, and to avoid doing excess I/O when the CPU has spare cycles that can be used for uncompressing compressed pages (that may already be in memory). When the system is I/O-bound, the algorithm prefers to evict the uncompressed copy of a page rather than both copies, to make more room for other disk pages to become memory resident. When the system is CPU-bound, InnoDB prefers to evict both the compressed and uncompressed page, so that more memory can be used for “hot” pages and reducing the need to uncompress data in memory only in compressed form.
Se esta duplicação de conteúdo de dados está acontecendo no Buffer Pool, você precisa aumentar innodb_buffer_pool_size por um pequeno fator linear da nova taxa de compactação. Aqui está como:
CENÁRIO
- Você tem um servidor de banco de dados com um pool de buffers 8G
- Você executou a compactação com
key_block_size=8
-
8
é50.00%
de16
-
50.00%
de8G
é4G
- aumentar
innodb_buffer_pool_size
para12G
(8G
+4G
)
-
- Você executou a compactação com
key_block_size=4
-
4
é25.00%
de16
-
25.00%
de8G
é2G
- aumentar
innodb_buffer_pool_size
para10G
(8G
+2G
)
-
- Você executou a compactação com
key_block_size=2
-
2
é12.50%
de16
-
12.50%
de8G
é1G
- aumentar
innodb_buffer_pool_size
para9G
(8G
+1G
)
-
- Você executou a compactação com
key_block_size=1
-
1
é06.25%
de16
-
06.25%
de8G
é0.5G
(512M
) - aumentar
innodb_buffer_pool_size
para8704M
(8G
(8192M
) +512M
)
-
MORAL DA HISTÓRIA : O InnoDB Buffer Pool precisa de mais espaço para respirar ao manipular dados compactados e páginas de índice.