[MDEV-8696] Adding indexes on empty table is slow with large innodb_sort_buffer_size. Created: 2015-08-28 Updated: 2016-02-16 Resolved: 2015-10-27 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB, Storage Engine - XtraDB |
| Affects Version/s: | 10.0.21 |
| Fix Version/s: | 10.0.22 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Jean-François Gagné | Assignee: | Jan Lindström (Inactive) |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Environment: |
CentOS release 6.6 |
||
| Description |
|
Hi, I am creating a table without indexes and then adding indexes to the table. The table definition is the following: CREATE TABLE `test_wo_keys` ( and the indexes are the following: ALTER TABLE test_wo_keys When I create the table and add the indexes without previously inserting data in the table (empty table), it works as expected with "innodb_sort_buffer_size = 1M" but it is slow with "innodb_sort_buffer_size = 64M": > SHOW GLOBAL VARIABLES LIKE 'innodb_sort_buffer_size';
------------------------
------------------------ > CREATE TABLE `test_wo_keys` ( > ALTER TABLE test_wo_keys > SHOW GLOBAL VARIABLES LIKE 'innodb_sort_buffer_size';
------------------------
------------------------ > CREATE TABLE `test_wo_keys` ( > ALTER TABLE test_wo_keys This is unexpected and should probably be optimized. Thanks, JFG |
| Comments |
| Comment by Jan Lindström (Inactive) [ 2015-09-01 ] |
|
Current code will write and read at least one block (sort_buffer_size bytes) from disk / index even if that block does not contain any records. This should be fixed. Ideally, if one sort buffer contains all the index records it should not be written or read from disk, we should be able to use memory buffers (this could be bigger change than above easy case). |
| Comment by Jan Lindström (Inactive) [ 2015-09-01 ] |
|
Verified by debugging that MySQL 5.7.7-rc does not physically read/write any blocks on empty table. Our current plan is to merge InnoDB 5.7 to MariaDB 10.2. This naturally, will not help MariaDB 10.0 or 10.1. |
| Comment by Jean-François Gagné [ 2015-09-01 ] |
|
Hi Jan, this plan looks good to me: this bug is minor. Thanks, |
| Comment by Jan Lindström (Inactive) [ 2015-10-27 ] |
|
commit 13884cf206c7e1a828748173a4d723cfe186fd8a Analysis: Current implementation will write and read at least one block Fix: Avoid writing / reading empty blocks to temporary files (disk). |