Commit 33e52ad
committed
Fix ndistinct estimates with system attributes
When estimating the number of groups using extended statistics, the code
was discarding information about system attributes. This led to strange
situation that
SELECT 1 FROM t GROUP BY ctid;
could have produced higher estimate (equal to pg_class.reltuples) than
SELECT 1 FROM t GROUP BY a, b, ctid;
with extended statistics on (a,b). Fixed by retaining information about
the system attribute.
Backpatch all the way to 10, where extended statistics were introduced.
Author: Tomas Vondra
Backpatch-through: 101 parent a14a011 commit 33e52ad
File tree
2 files changed
+4
-4
lines changed- src
- backend/utils/adt
- test/regress/expected
2 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3987 | 3987 | | |
3988 | 3988 | | |
3989 | 3989 | | |
3990 | | - | |
| 3990 | + | |
| 3991 | + | |
3991 | 3992 | | |
3992 | 3993 | | |
3993 | | - | |
3994 | | - | |
| 3994 | + | |
3995 | 3995 | | |
3996 | 3996 | | |
3997 | 3997 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
0 commit comments