postgresql/src/include
Tom Lane 2b74303637 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 a
VALUES column, we fell back on the default behavior used whenever we lack
statistics, 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 reliable
info if the entries are not all constants.  What seems like a better choice
is to assume that the values are all distinct.  This will sometimes be just
as wrong as the old code, but it seems more likely to be more nearly right
in many common cases.  Also, it is more consistent with what happens in
some related cases, for example WHERE x = ANY(ARRAY[1,2,3,...,n]) and
WHERE x = ANY(VALUES (1),(2),(3),...,(n)) now are estimated similarly.

This was discussed some time ago, but consensus was it'd be better
to 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.com
2017-08-16 15:37:20 -04:00
..
access Use atomic ops to hand out pages to scan in parallel scan. 2017-08-16 16:18:41 +03:00
bootstrap Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catalog Assorted preparatory refactoring for partition-wise join. 2017-08-15 12:30:38 -04:00
commands Final pgindent + perltidy run for v10. 2017-08-14 17:29:33 -04:00
common Update copyright in recently added files 2017-07-26 18:17:18 -04:00
datatype Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
executor Move ExecProcNode from dispatch to function pointer based model. 2017-07-30 16:18:21 -07:00
fe_utils Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
foreign Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
lib Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
libpq Always use 2048 bit DH parameters for OpenSSL ephemeral DH ciphers. 2017-07-31 22:36:09 +03:00
mb Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
nodes Make the planner assume that the entries in a VALUES list are distinct. 2017-08-16 15:37:20 -04:00
optimizer Assorted preparatory refactoring for partition-wise join. 2017-08-15 12:30:38 -04:00
parser Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
port Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
portability Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postmaster Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
regex Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
replication Fix replication origin-related race conditions 2017-08-08 16:07:46 -04:00
rewrite Teach map_partition_varattnos to handle whole-row expressions. 2017-08-03 11:21:29 -04:00
snowball Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
statistics Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
storage Distinguish wait-for-connection from wait-for-write-ready on Windows. 2017-08-15 11:07:57 -04:00
tcop Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
tsearch Fix serious performance problems in json(b) to_tsvector(). 2017-07-18 12:45:51 -04:00
utils Avoid out-of-memory in a hash join with many duplicate inner keys. 2017-08-15 14:05:53 -04:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Fix shm_toc.c to always return buffer-aligned memory. 2017-08-16 21:52:38 +03:00
fmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
funcapi.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
getaddrinfo.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
getopt_long.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
Makefile Add statistics subdirectory to Makefile. 2017-06-08 11:29:50 -04:00
miscadmin.h Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
pg_config.h.in Reject use of ucol_strcollUTF8() before ICU 53 2017-08-10 22:14:00 -04:00
pg_config.h.win32 Stamp HEAD as 11devel. 2017-08-14 18:08:30 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix default minimum value for descending sequences 2017-01-23 14:00:58 -05:00
pg_getopt.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_trace.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pgstat.h Fix replication origin-related race conditions 2017-08-08 16:07:46 -04:00
pgtar.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
pgtime.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
port.h Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
postgres.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rusagestub.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
windowapi.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00