]> granicus.if.org Git - postgresql/commit
postgres_fdw: Consider requesting sorted data so we can do a merge join.
authorRobert Haas <rhaas@postgresql.org>
Tue, 22 Dec 2015 18:46:40 +0000 (13:46 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 22 Dec 2015 18:46:40 +0000 (13:46 -0500)
commitccd8f97922944566d26c7d90eb67ab7848ee9905
tree8814b156ad06bec086fe3ec5bed67f7be29fb4dc
parentf5a4370aea3580f5f7f59a77e41fde62f2be12d8
postgres_fdw: Consider requesting sorted data so we can do a merge join.

When use_remote_estimate is enabled, consider adding ORDER BY to the
query we sending to the remote server so that we can use that ordered
data for a merge join.  Commit f18c944b6137329ac4a6b2dce5745c5dc21a8578
arranges to push down the query pathkeys, which seems like the case
mostly likely to be a win, but testing shows this can sometimes win,
too.

For a regular table, we know which indexes are present and therefore
test whether the ordering provided by each such index is useful.  Here,
we take the opposite approach: guess what orderings would be useful if
they could be generated cheaply, and then ask the remote side what those
will cost.

Ashutosh Bapat, with very substantial cosmetic revisions by me.  Also
reviewed by Rushabh Lathia.
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/postgres_fdw.c
contrib/postgres_fdw/sql/postgres_fdw.sql
src/backend/optimizer/path/pathkeys.c
src/include/optimizer/paths.h