[MDEV-33087] ALTER TABLE...ALGORITHM=COPY should build indexes more efficiently Created: 2023-12-20 Updated: 2024-01-30 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Storage Engine - InnoDB |
| Affects Version/s: | 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4 |
| Fix Version/s: | 10.11, 11.0, 11.1, 11.2, 11.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marko Mäkelä | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | performance | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
As noted in I tested this on MariaDB Server 11.2, which implements
I set a breakpoint inside ha_innobase::extra(HA_EXTRA_END_ALTER_COPY) and started to debug its surroundings:
For the first statement that hits the first breakpoint (alter table t1 add b int NULL, algorithm= copy, lock= none), we can see that the row-level undo logging is being disabled as expected (
Because this code path provides a work-around for It would be good to test the fix on 11.2 before applying it to the earliest supported version (10.11), because |
| Comments |
| Comment by Marko Mäkelä [ 2023-12-20 ] | ||||||||
|
Related to this, while CREATE TABLE…SELECT is disabling the row-by-row undo logging, it currently uses the inefficient row_ins() API:
For the above SQL, only the INSERT…SELECT will invoke the more efficient trx_t::bulk_insert_apply(). | ||||||||
| Comment by Marko Mäkelä [ 2023-12-20 ] | ||||||||
|
If foreign_key_checks=1 (the default) and there are any FOREIGN KEY…REFERENCES clauses in the table that is being altered, then I think that we must keep using the row-by-row interface, so that row_ins_check_foreign_constraints() will check the FOREIGN KEY constraints. This is something that could be improved later in MDEV-16356. |