[MDEV-21472] ALTER TABLE ... ANALYZE PARTITION ... with EITS reads and locks all rows in the table Created: 2020-01-14 Updated: 2024-01-30 Resolved: 2020-07-29 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Partitioning |
| Affects Version/s: | 10.1.34, 10.2.31 |
| Fix Version/s: | 10.1.46, 10.2.33, 10.3.24, 10.4.14, 10.5.5 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Valerii Kravchuk | Assignee: | Michael Widenius |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | eits | ||
| Description |
|
When EITS is enabled, ALTER TABLE ... ANALYZE PARTITION reads (and locks) all rows in the InnoDB table, even for a tiny partition. As a result, for huge tables it may work for hours and days and does not server the purpose. This does NOT happen without engine-independent persistent statistics enabled. Consider this table:
This is how long it takes to get statistics for the partition with just 9 rows:
In the INNODB STATUS output taken when this query runs we see:
So, the statement that should access single partition with just 9 rows reads and locks all rows in the table. As a result it is totally useless, One can just run ANALYZE for the entire table with the same "costs". |
| Comments |
| Comment by Sergei Petrunia [ 2020-07-25 ] | |||||||||||
|
So how about this solution for versions that are currently GA:
This looks consistent to me, and will solve the customer' complaint. The patch to implement this is a one-liner:
For subsequent versions, we could look at collecting statistics for each partition. When that is implemented, we will make ANALYZE PARTITION to collect EITS stats if use_stat_tables setting requires it. | |||||||||||
| Comment by Valerii Kravchuk [ 2020-07-26 ] | |||||||||||
|
I think the idea makes sense. If EITS is needed for the entire table there is still a way to get it, but the attempt of per partition collecftion will not cause a lot of unexpected row reads. Maybe add a warning or note that EITS is not really collected in frames of this change. | |||||||||||
| Comment by Sergei Petrunia [ 2020-07-29 ] | |||||||||||
|
... also ran it through on the Optimizer Call yesterday. No objections. https://github.com/MariaDB/server/commit/7e9ffc69ecd1bddf731391b01e6be221efb6f8ef | |||||||||||
| Comment by Michael Widenius [ 2024-01-29 ] | |||||||||||
|
This issue was fixed in 10.2 but merging the code to 10.3 disabled the change. |