| Bug #114964 | update statistics for a specified index | ||
|---|---|---|---|
| Submitted: | 11 May 2024 6:36 | Modified: | 14 May 2024 3:26 |
| Reporter: | Boy Zhang | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | MySQL Server: DDL | Severity: | S3 (Non-critical) |
| Version: | 8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | add index, statistics | ||
[13 May 2024 10:55]
MySQL Verification Team
HI Mr. Zhang, Thank you for your bug report. However, we do not see a test case for your report. We also do not fully understand the feature that you are asking for. Doesn't ANAlYZE TABLE do its job or not ??? Many thanks in advance.
[14 May 2024 3:26]
Boy Zhang
Sorry, maybe the previous description was not clear. The problem I want to describe here is that when adding index, statistics will be collected for the new index, and only the statistics of this index need to be saved. However, the statistics of all indexes is currently saved. The reason is that there is a problem with the only_for_index judgment logic in the dict_stats_save() function. This may be a bug.
[14 May 2024 10:36]
MySQL Verification Team
Hi Mr. Zhang, Actually, this is intended behaviour. If you find that our Reference Manual says otherwise, please let us know and refer us to the description that is wrong. Thanks in advance.

Description: When executing DDL such as add index or create index, you only need to collect statistics and save statistics of the specified index. However, the only_for_index parameter in the dict_stats_save() function does not work. In fact, the statistics of all indexes will be persisted. How to repeat: create table customer( c_custkey integer not null, c_name varchar(25) not null, c_address varchar(40) not null, c_nationkey integer not null, c_phone char(15) not null, c_acctbal decimal(15,2) not null, c_mktsegment char(10) not null, c_comment varchar(117) not null, primary key (c_custkey)); create index c_nationkey_idx on customer(c_nationkey); Suggested fix: if (only_for_index != nullptr && (index->space != only_for_index->m_space_id || index->id != only_for_index->m_index_id)) { continue; }