]> granicus.if.org Git - postgresql/commit
Fix planning of parameterized appendrel paths with expensive join quals.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 8 Jul 2013 02:37:28 +0000 (22:37 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 8 Jul 2013 02:37:28 +0000 (22:37 -0400)
commit8b6191e1d5e48d521c42d5f6bdbf8413874f7206
tree495f2ad69cd0ee8d5533fbc83d7ae1338ab45970
parent95b4e8761e3aac9d27c59b89eb3ca5c90d93f9da
Fix planning of parameterized appendrel paths with expensive join quals.

The code in set_append_rel_pathlist() for building parameterized paths
for append relations (inheritance and UNION ALL combinations) supposed
that the cheapest regular path for a child relation would still be cheapest
when reparameterized.  Which might not be the case, particularly if the
added join conditions are expensive to compute, as in a recent example from
Jeff Janes.  Fix it to compare child path costs *after* reparameterizing.
We can short-circuit that if the cheapest pre-existing path is already
parameterized correctly, which seems likely to be true often enough to be
worth checking for.

Back-patch to 9.2 where parameterized paths were introduced.
src/backend/optimizer/path/allpaths.c
src/test/regress/expected/union.out
src/test/regress/sql/union.sql