Commit 10b447c
committed
ORCA: strip trailing spaces from bpchar payload in stats LINT mapping
PG's bpchareq treats trailing spaces as insignificant: a char(50) MCV
stored as 'Books' is space-padded to 50 bytes in pg_statistic, while a
query constant ``i_category='Books'`` arrives unpadded. In
ExtractLintValueFromDatum the two produce different sort-key prefixes
and therefore different LINTs, so CDatumGenericGPDB::StatsAreEqual
(via IDatum::StatsAreEqual on the LINT mapping) misses every MCV
bucket -- ORCA falls back to MinRows = 1 and downstream plans go
wildly wrong (e.g. TPC-DS sf=5 Q33 estimates 1 row for i_category
='Books', actual 5331, then cascades into a 14M-row IndexNL).
Trim trailing ASCII spaces from the bpchar payload before feeding it
to the locale sort-key transform. Only the LINT path is affected;
the round-tripped varlena bytes are preserved so that bpchar
constants in INSERT/SELECT plans still carry their declared padding.1 parent 92bba5f commit 10b447c
1 file changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2659 | 2659 | | |
2660 | 2660 | | |
2661 | 2661 | | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
2662 | 2678 | | |
2663 | 2679 | | |
2664 | 2680 | | |
| |||
0 commit comments