[MDEV-14007] Automatic statistics recalculation for MyISAM and Aria Created: 2017-10-05 Updated: 2019-05-16 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Storage Engine - Aria, Storage Engine - MyISAM |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Richard Stracke | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Cardinality for non-unique index will not updated, until one row was inserted and Create Statement.
I would expect cardinality a not NULL like for Index CAMP01. An Analyze does not help; ANALYZE TABLE TAB1;
Message "Table is already up to to date" is wrong. Output of show index from TAB1; is still the same.
If I insert two values.
The cardinality of the PK CAMP01 was updated, the cardinality of CAMP02 is still NULL. Now a analyze table can help.
Now cardinality is as expected. Adding an additional value.
Now cardinality will be updated as expected. Both indices cardinality was updated. Expected behaviour would be, that cardinality from non-unique index was updated in the same way like unique keys. Richard |
| Comments |
| Comment by Elena Stepanova [ 2017-10-06 ] |
|
Could you please clarify examples in the description – which exactly part you consider a bug, what is the desired result, and why you expect INSERTs on one table (TAB1) to have any effect on another table (TAB2)? |
| Comment by Richard Stracke [ 2017-10-10 ] |
|
Hello Elena, I made the tests with MyISAM and Aria to be sure, I mixed up the tablenames. I update the whole report, I hope now it is more clearly. Richard |
| Comment by Elena Stepanova [ 2017-10-10 ] |
|
First of all, I think there is a general misunderstanding here. MyISAM or Aria generally do not collect statistics upon populating a table, one must run ANALYZE for that. It is not a bug, it is an implementation specifics. It is certainly documented in MySQL manual, e.g. here https://dev.mysql.com/doc/refman/5.7/en/show-index.html ; I can't say whether it's documented in MariaDB KB, if it isn't, it should be added. Also, there are parts of the description that seem confusing. Let's go through the s one by one.
So, we have three separate directions here:
Which do you want to pursue? If you want automatic recalculation, I can convert this bug report into a feature request. If you want the suspected issues to be addressed, please paste the complete totally unabridged output from the MySQL client, and also attach your cnf file(s) (but keep in mind that after fixing results might be even more different from your expectations than they are now). If you want the current behavior to be documented, I will re-categorize it. |
| Comment by Richard Stracke [ 2017-10-24 ] |
|
It is not clear documented. Quote from "Cardinality I assume the this has historical reasons. What is irritating is the inconsistent behavior. I changed expected cardinality amount to updated or not. For "minor issues in recalculation" I would create a new MDEV with more accurat details. Regards, Richard |
| Comment by Elena Stepanova [ 2017-10-30 ] |
Richard, do I understand it correctly that you want it to be a feature request for automatic statistics recalculation for the above-mentioned engines? |
| Comment by Richard Stracke [ 2017-11-02 ] |
Yes |
| Comment by Michael Widenius [ 2019-03-12 ] |
|
Statistics and how they they are calculated are engine dependent. Depending on the design of the engine, it can provide more or less accurate statistics without running an ANALYZE TABLE. The basic usage case of when to update index statistics:
I agree with Elena's first comment that for an empty table, the default cardinality is probably right, or at least not wrong. |