diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-02-09 14:00:50 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-02-09 14:00:50 -0500 |
commit | e4106b2528727c4b48639c0e12bf2f70a766b910 (patch) | |
tree | d22a96438d65f4cdd6537ab7787296e6bf14b190 /contrib/postgres_fdw/postgres_fdw.h | |
parent | 7351e18286ec83461b386e23328d65fd4a538bba (diff) | |
download | postgresql-e4106b2528727c4b48639c0e12bf2f70a766b910.tar.gz postgresql-e4106b2528727c4b48639c0e12bf2f70a766b910.zip |
postgres_fdw: Push down joins to remote servers.
If we've got a relatively straightforward join between two tables,
this pushes that join down to the remote server instead of fetching
the rows for each table and performing the join locally. Some cases
are not handled yet, such as SEMI and ANTI joins. Also, we don't
yet attempt to create presorted join paths or parameterized join
paths even though these options do get tried for a base relation
scan. Nevertheless, this seems likely to be a very significant win
in many practical cases.
Shigeru Hanada and Ashutosh Bapat, reviewed by Robert Haas, with
additional review at various points by Tom Lane, Etsuro Fujita,
KaiGai Kohei, and Jeevan Chalke.
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.h')
-rw-r--r-- | contrib/postgres_fdw/postgres_fdw.h | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.h b/contrib/postgres_fdw/postgres_fdw.h index 2b632817fec..4c731becc68 100644 --- a/contrib/postgres_fdw/postgres_fdw.h +++ b/contrib/postgres_fdw/postgres_fdw.h @@ -26,7 +26,25 @@ */ typedef struct PgFdwRelationInfo { - /* baserestrictinfo clauses, broken down into safe and unsafe subsets. */ + /* + * True means that the relation can be pushed down. Always true for simple + * foreign scan. + */ + bool pushdown_safe; + + /* + * Restriction clauses, divided into safe and unsafe to pushdown subsets. + * + * For a base foreign relation this is a list of clauses along-with + * RestrictInfo wrapper. Keeping RestrictInfo wrapper helps while dividing + * scan_clauses in postgresGetForeignPlan into safe and unsafe subsets. + * Also it helps in estimating costs since RestrictInfo caches the + * selectivity and qual cost for the clause in it. + * + * For a join relation, however, they are part of otherclause list + * obtained from extract_actual_join_clauses, which strips RestrictInfo + * construct. So, for a join relation they are list of bare clauses. + */ List *remote_conds; List *local_conds; @@ -37,11 +55,17 @@ typedef struct PgFdwRelationInfo QualCost local_conds_cost; Selectivity local_conds_sel; - /* Estimated size and cost for a scan with baserestrictinfo quals. */ + /* Selectivity of join conditions */ + Selectivity joinclause_sel; + + /* Estimated size and cost for a scan or join. */ double rows; int width; Cost startup_cost; Cost total_cost; + /* Costs excluding costs for transferring data from the foreign server */ + Cost rel_startup_cost; + Cost rel_total_cost; /* Options extracted from catalogs. */ bool use_remote_estimate; @@ -55,6 +79,19 @@ typedef struct PgFdwRelationInfo UserMapping *user; /* only set in use_remote_estimate mode */ int fetch_size; /* fetch size for this remote table */ + + /* + * Name of the relation while EXPLAINing ForeignScan. It is used for join + * relations but is set for all relations. For join relation, the name + * indicates which foreign tables are being joined and the join type used. + */ + StringInfo relation_name; + + /* Join information */ + RelOptInfo *outerrel; + RelOptInfo *innerrel; + JoinType jointype; + List *joinclauses; } PgFdwRelationInfo; /* in postgres_fdw.c */ @@ -102,12 +139,15 @@ extern void deparseAnalyzeSql(StringInfo buf, Relation rel, List **retrieved_attrs); extern void deparseStringLiteral(StringInfo buf, const char *val); extern Expr *find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel); +extern List *build_tlist_to_deparse(RelOptInfo *foreign_rel); extern void deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, - RelOptInfo *baserel, List *remote_conds, List *pathkeys, + RelOptInfo *foreignrel, List *tlist, + List *remote_conds, List *pathkeys, List **retrieved_attrs, List **params_list); /* in shippable.c */ extern bool is_builtin(Oid objectId); extern bool is_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo); +extern const char *get_jointype_name(JoinType jointype); #endif /* POSTGRES_FDW_H */ |