Commit d0ac583
MDEV-36761 Implement NULL-aware cardinality estimation for indexed columns
(Preparation for the main patch)
set_statistics_for_table() incorrectly treated indexes with all NULL
values the same as indexes with no statistics, because avg_frequency
is 0 in both cases. This caused the optimizer to ignore valid EITS
data and fall back to engine statistics.
Additionally, KEY::actual_rec_per_key() would fall back to engine
statistics even when EITS was available, and used incorrect pointer
comparison (rec_per_key == 0 instead of nullptr).
Fix by adding Index_statistics::stats_were_read flag to track per-index
whether statistics were actually read from persistent tables, and
restructuring actual_rec_per_key() to prioritize EITS when available.1 parent 75ded7d commit d0ac583
3 files changed
+23
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3120 | 3120 | | |
3121 | 3121 | | |
3122 | 3122 | | |
| 3123 | + | |
3123 | 3124 | | |
| 3125 | + | |
| 3126 | + | |
3124 | 3127 | | |
3125 | 3128 | | |
3126 | 3129 | | |
| |||
4157 | 4160 | | |
4158 | 4161 | | |
4159 | 4162 | | |
4160 | | - | |
| 4163 | + | |
4161 | 4164 | | |
4162 | 4165 | | |
4163 | 4166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
606 | 607 | | |
607 | 608 | | |
608 | 609 | | |
609 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
610 | 619 | | |
611 | 620 | | |
612 | 621 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10299 | 10299 | | |
10300 | 10300 | | |
10301 | 10301 | | |
10302 | | - | |
10303 | | - | |
10304 | | - | |
10305 | | - | |
| 10302 | + | |
| 10303 | + | |
| 10304 | + | |
| 10305 | + | |
| 10306 | + | |
| 10307 | + | |
| 10308 | + | |
| 10309 | + | |
| 10310 | + | |
10306 | 10311 | | |
10307 | 10312 | | |
10308 | 10313 | | |
| |||
0 commit comments