Commit fac6611
authored
Fix colNDVBySeg attnum index mismatch in column-specific ANALYZE (#1680)
* Fix colNDVBySeg index mismatch in do_analyze_rel
When ANALYZE is run on specific columns (e.g., ANALYZE t (col)) or when
a table has dropped columns, the vacattrstats loop index `i` diverges
from the attribute's actual attnum-1 index used by colNDVBySeg.
Two fixes:
1. QD side (line 887): read colNDVBySeg[attnum-1] instead of
colNDVBySeg[i] when storing stadistinctbyseg.
2. Segment side (line 1011): write ctx->stadistincts[attnum-1] instead
of ctx->stadistincts[i] when collecting per-segment NDV.
* Add regression test for colNDVBySeg index mismatch in do_analyze_rel
ANALYZE t(b) puts column b at loop index i=0 on the QD, but b has
attnum=2, so attnum-1=1 != i=0. The fix in do_analyze_rel (using
attnum-1 instead of i to index colNDVBySeg) ensures stadistinctbyseg
is read from the correct per-segment NDV slot.
Test verifies stadistinctbyseg for column b equals 100 (all distinct)
rather than ~5 (NDV of column a at index 0).1 parent bff7715 commit fac6611
3 files changed
Lines changed: 52 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | | - | |
| 887 | + | |
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
| |||
1008 | 1008 | | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | | - | |
| 1011 | + | |
1012 | 1012 | | |
1013 | 1013 | | |
1014 | 1014 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1314 | 1314 | | |
1315 | 1315 | | |
1316 | 1316 | | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
0 commit comments