forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2b74303
committed
Make the planner assume that the entries in a VALUES list are distinct.
Previously, if we had to estimate the number of distinct values in aVALUES column, we fell back on the default behavior used whenever we lackstatistics, which effectively is that there are Min(# of entries, 200)distinct values. This can be very badly off with a large VALUES list,as noted by Jeff Janes.We could consider actually running an ANALYZE-like scan on the VALUES,but that seems unduly expensive, and anyway it could not deliver reliableinfo if the entries are not all constants. What seems like a better choiceis to assume that the values are all distinct. This will sometimes be justas wrong as the old code, but it seems more likely to be more nearly rightin many common cases. Also, it is more consistent with what happens insome related cases, for example WHERE x = ANY(ARRAY[1,2,3,...,n]) andWHERE x = ANY(VALUES (1),(2),(3),...,(n)) now are estimated similarly.This was discussed some time ago, but consensus was it'd be betterto slip it in at the start of a development cycle not near the end.(It should've gone into v10, really, but I forgot about it.)Discussion:https://postgr.es/m/CAMkU=1xHkyPa8VQgGcCNg3RMFFvVxUdOpus1gKcFuvVi0w6Acg@mail.gmail.com1 parentac883ac commit2b74303
2 files changed
+13
-2
lines changedLines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5009 | 5009 |
| |
5010 | 5010 |
| |
5011 | 5011 |
| |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
5012 | 5023 |
| |
5013 | 5024 |
| |
5014 | 5025 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 |
| - | |
| 410 | + | |
411 | 411 |
| |
412 | 412 |
| |
413 | 413 |
| |
| |||
552 | 552 |
| |
553 | 553 |
| |
554 | 554 |
| |
555 |
| - | |
| 555 | + | |
556 | 556 |
| |
557 | 557 |
| |
558 | 558 |
| |
|
0 commit comments
Comments
(0)