postgresql/src/test/regress
Tom Lane 959d00e9db Use Append rather than MergeAppend for scanning ordered partitions.
If we need ordered output from a scan of a partitioned table, but
the ordering matches the partition ordering, then we don't need to
use a MergeAppend to combine the pre-ordered per-partition scan
results: a plain Append will produce the same results.  This
both saves useless comparison work inside the MergeAppend proper,
and allows us to start returning tuples after istarting up just
the first child node not all of them.

However, all is not peaches and cream, because if some of the
child nodes have high startup costs then there will be big
discontinuities in the tuples-returned-versus-elapsed-time curve.
The planner's cost model cannot handle that (yet, anyway).
If we model the Append's startup cost as being just the first
child's startup cost, we may drastically underestimate the cost
of fetching slightly more tuples than are available from the first
child.  Since we've had bad experiences with over-optimistic choices
of "fast start" plans for ORDER BY LIMIT queries, that seems scary.
As a klugy workaround, set the startup cost estimate for an ordered
Append to be the sum of its children's startup costs (as MergeAppend
would).  This doesn't really describe reality, but it's less likely
to cause a bad plan choice than an underestimated startup cost would.
In practice, the cases where we really care about this optimization
will have child plans that are IndexScans with zero startup cost,
so that the overly conservative estimate is still just zero.

David Rowley, reviewed by Julien Rouhaud and Antonin Houska

Discussion: https://postgr.es/m/CAKJS1f-hAqhPLRk_RaSFTgYxd=Tz5hA7kQ2h4-DhJufQk8TGuw@mail.gmail.com
2019-04-05 19:20:43 -04:00
..
data Improve key representation for GIN jsonb_ops, and fix existence-search bug. 2014-05-09 08:41:26 -04:00
expected Use Append rather than MergeAppend for scanning ordered partitions. 2019-04-05 19:20:43 -04:00
input Build out the planner support function infrastructure. 2019-02-09 18:32:23 -05:00
output Build out the planner support function infrastructure. 2019-02-09 18:32:23 -05:00
sql Use Append rather than MergeAppend for scanning ordered partitions. 2019-04-05 19:20:43 -04:00
.gitignore Update .gitignore for config.cache. 2014-12-18 19:56:42 +09:00
GNUmakefile Unified logging system for command-line programs 2019-04-01 20:01:35 +02:00
Makefile Fix non-GNU makefiles for AIX make. 2017-11-30 00:57:22 -08:00
parallel_schedule Generated columns 2019-03-30 08:15:57 +01:00
pg_regress.c Unified logging system for command-line programs 2019-04-01 20:01:35 +02:00
pg_regress.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_regress_main.c tableam: introduce table AM infrastructure. 2019-03-06 09:54:38 -08:00
README Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:04 -05:00
regress.c Build out the planner support function infrastructure. 2019-02-09 18:32:23 -05:00
regressplans.sh Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00
resultmap Cygwin and Mingw floating-point fixes. 2019-02-16 01:50:16 +00:00
serial_schedule Generated columns 2019-03-30 08:15:57 +01:00
standby_schedule Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00

Documentation concerning how to run these regression tests and interpret
the results can be found in the PostgreSQL manual, in the chapter
"Regression Tests".