diff options
author | Robert Haas <rhaas@postgresql.org> | 2015-12-22 13:46:40 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2015-12-22 13:46:40 -0500 |
commit | ccd8f97922944566d26c7d90eb67ab7848ee9905 (patch) | |
tree | 8814b156ad06bec086fe3ec5bed67f7be29fb4dc /src | |
parent | f5a4370aea3580f5f7f59a77e41fde62f2be12d8 (diff) | |
download | postgresql-ccd8f97922944566d26c7d90eb67ab7848ee9905.tar.gz postgresql-ccd8f97922944566d26c7d90eb67ab7848ee9905.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/path/pathkeys.c | 5 | ||||
-rw-r--r-- | src/include/optimizer/paths.h | 3 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index c6b5d78724b..b81cc49f0ab 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -28,9 +28,6 @@ #include "utils/lsyscache.h" -static PathKey *make_canonical_pathkey(PlannerInfo *root, - EquivalenceClass *eclass, Oid opfamily, - int strategy, bool nulls_first); static bool pathkey_is_redundant(PathKey *new_pathkey, List *pathkeys); static bool right_merge_direction(PlannerInfo *root, PathKey *pathkey); @@ -50,7 +47,7 @@ static bool right_merge_direction(PlannerInfo *root, PathKey *pathkey); * equivclass.c will complain if a merge occurs after root->canon_pathkeys * has become nonempty.) */ -static PathKey * +PathKey * make_canonical_pathkey(PlannerInfo *root, EquivalenceClass *eclass, Oid opfamily, int strategy, bool nulls_first) diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 7757741c104..4e00e9f474b 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -206,5 +206,8 @@ extern List *truncate_useless_pathkeys(PlannerInfo *root, RelOptInfo *rel, List *pathkeys); extern bool has_useful_pathkeys(PlannerInfo *root, RelOptInfo *rel); +extern PathKey *make_canonical_pathkey(PlannerInfo *root, + EquivalenceClass *eclass, Oid opfamily, + int strategy, bool nulls_first); #endif /* PATHS_H */ |