diff options
| author | Mason Sharp | 2010-11-03 17:06:24 +0000 |
|---|---|---|
| committer | Pavan Deolasee | 2011-05-19 16:45:21 +0000 |
| commit | feeca12a27a8233428daf5187728dd6771ef194d (patch) | |
| tree | 56d750bd1168862cc9e777ab8c54e20ceb8972e1 /src/include | |
| parent | f6cb9c4ebdbdf00027aec825b73b3b961156ed19 (diff) | |
Improve performance of "multi-step" queries (an on-going process).
We already had code that detected when we can reduce the entire query
to a single step, including joins. We also had general code that
allowed for handling arbitrary queries that could not be reduced
into one step, with the catch that joins will be done at the
coordinator level.
This commit allows for some joins to be pushed down when possible.
For example, in a three-way join, if two tables are co-located,
they may be joined in a single step down at the data nodes, and
those results will be joined with the third table (on the
coordinator, however).
In addition, the previous code was based on a SQL/MED patch,
which meant when accessing remote tables, it selected all of
the columns. With this commit, we project only the needed columns.
Written primarily by Pavan Deolasee (join push-dwon and column selection)
and Mason Sharp (safe push-down detection).
Squashed commit of the following:
commit eb50a76cb929fbe4a31d093b43e1589382c892a0
Author: Pavan Deolasee <pavan.deolasee@gmail.com>
Date: Wed Oct 27 16:09:28 2010 +0530
Set remote relation stats (pages, rows etc) to a lower value so that
NestLoop joins are preferred over other join types. This is necessary
until we can handle other join types for remote join reduction
commit 69bb66c62f71b9be918475ea65931adb3bbfba20
Author: Pavan Deolasee <pavan.deolasee@gmail.com>
Date: Tue Oct 19 12:20:44 2010 +0530
Set aliases properly for join reduction
commit 2a313446f3e714ba36c9ccc5c5167309b7c89a95
Author: Mason Sharp <mason_s@users.sourceforge.net>
Date: Mon Oct 18 16:15:16 2010 -0400
Added IsJoinReducible to determine if the two plan nodes can be joined.
See comments for this function for more details. Basically, we use
examine_conditions_walker to check if it is safe to join the two.
Partitioned-partitioned joins are safe to collapse, and
partitioned-replicated are safe iff one of the nodes does not already
contain such a collapsed node.
commit f275fa535e9673af0964ecc7ca93ab1b49df2317
Author: Pavan Deolasee <pavan.deolasee@gmail.com>
Date: Mon Oct 18 11:53:54 2010 +0530
Fix a bug where rte/alias were not getting set up properly
commit 6af07721357944af801a384ed1eb54e363839403
Author: Pavan Deolasee <pavan.deolasee@gmail.com>
Date: Mon Oct 18 11:35:43 2010 +0530
Update some missing copy/out/read functions
commit 7bcb490dc50eeb1ad1569d90cc5eb759b766aa91
Author: Pavan Deolasee <pavan.deolasee@gmail.com>
Date: Mon Oct 18 11:33:54 2010 +0530
Initial implementation of remote join reduction. We still don't have
the logic to determine whether its safe to reduce two join trees or not
commit aefc06e7bd90c657fb093a923f7b66177687561d
Author: Pavan Deolasee <pavan.deolasee@gmail.com>
Date: Mon Oct 18 11:29:21 2010 +0530
First step to SQL-med integration. Moving query generation to planning stage
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/parsenodes.h | 8 | ||||
| -rw-r--r-- | src/include/nodes/relation.h | 9 | ||||
| -rw-r--r-- | src/include/optimizer/cost.h | 3 | ||||
| -rw-r--r-- | src/include/optimizer/planmain.h | 3 | ||||
| -rw-r--r-- | src/include/optimizer/var.h | 3 | ||||
| -rw-r--r-- | src/include/pgxc/planner.h | 17 | ||||
| -rw-r--r-- | src/include/utils/builtins.h | 3 |
7 files changed, 46 insertions, 0 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 6250de3774..355c44847e 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -24,6 +24,9 @@ #include "nodes/bitmapset.h" #include "nodes/primnodes.h" #include "nodes/value.h" +#ifdef PGXC +#include "access/tupdesc.h" +#endif /* Possible sources of a Query */ typedef enum QuerySource @@ -660,6 +663,11 @@ typedef struct RangeTblEntry * code that is being actively worked on. FIXME someday. */ +#ifdef PGXC + char *relname; + TupleDesc reltupdesc; +#endif + /* * Fields valid for a plain relation RTE (else zero): */ diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 7eb15dbeec..4acd48bbcb 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -189,6 +189,11 @@ typedef struct PlannerInfo * pseudoconstant = true */ bool hasRecursion; /* true if planning a recursive WITH item */ +#ifdef PGXC + /* This field is used only when RemoteScan nodes are involved */ + int rs_alias_index; /* used to build the alias reference */ +#endif + /* These fields are used only when hasRecursion is true: */ int wt_param_id; /* PARAM_EXEC ID for the work table */ struct Plan *non_recursive_plan; /* plan for non-recursive term */ @@ -377,6 +382,10 @@ typedef struct RelOptInfo * clauses */ List *index_inner_paths; /* InnerIndexscanInfo nodes */ +#ifdef PGXC + TupleDesc reltupdesc; +#endif + /* * Inner indexscans are not in the main pathlist because they are not * usable except in specific join contexts. We use the index_inner_paths diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index 839270f355..15cdf599a2 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -59,6 +59,9 @@ extern bool enable_hashagg; extern bool enable_nestloop; extern bool enable_mergejoin; extern bool enable_hashjoin; +#ifdef PGXC +extern bool enable_remotejoin; +#endif extern int constraint_exclusion; extern double clamp_row_est(double nrows); diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 3ffd80003a..2c3dcd4dbd 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -119,4 +119,7 @@ extern void extract_query_dependencies(List *queries, List **relationOids, List **invalItems); +#ifdef PGXC +extern Var *search_tlist_for_var(Var *var, List *jtlist); +#endif #endif /* PLANMAIN_H */ diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 5d19572e0d..0e7ac5f212 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -25,6 +25,9 @@ typedef enum extern Relids pull_varnos(Node *node); extern void pull_varattnos(Node *node, Bitmapset **varattnos); +#ifdef PGXC +extern Bitmapset * pull_varattnos_varno(Node *node, Index varno, Bitmapset *varattnos); +#endif extern bool contain_var_clause(Node *node); extern bool contain_vars_of_level(Node *node, int levelsup); extern int locate_var_of_level(Node *node, int levelsup); diff --git a/src/include/pgxc/planner.h b/src/include/pgxc/planner.h index 1e31fa38c1..8aae356fd2 100644 --- a/src/include/pgxc/planner.h +++ b/src/include/pgxc/planner.h @@ -23,6 +23,7 @@ #include "nodes/primnodes.h" #include "pgxc/locator.h" #include "tcop/dest.h" +#include "nodes/relation.h" typedef enum @@ -85,6 +86,18 @@ typedef struct bool read_only; /* do not use 2PC when committing read only steps */ bool force_autocommit; /* some commands like VACUUM require autocommit mode */ RemoteQueryExecType exec_type; + + char *relname; + bool remotejoin; /* True if this is a reduced remote join */ + bool partitioned_replicated; /* True if reduced and contains replicated-partitioned join */ + int reduce_level; /* in case of reduced JOIN, it's level */ + List *base_tlist; /* in case of isReduced, the base tlist */ + char *outer_alias; + char *inner_alias; + int outer_reduce_level; + int inner_reduce_level; + Relids outer_relids; + Relids inner_relids; } RemoteQuery; @@ -165,4 +178,8 @@ extern PlannedStmt *pgxc_planner(Query *query, int cursorOptions, extern bool IsHashDistributable(Oid col_type); extern bool is_immutable_func(Oid funcid); + +extern bool IsJoinReducible(RemoteQuery *innernode, RemoteQuery *outernode, + List *rtable_list, JoinPath *join_path, bool *partitioned_replicated); + #endif /* PGXCPLANNER_H */ diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 90955b73f9..4b1463ff74 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -595,7 +595,10 @@ extern Datum pg_get_function_identity_arguments(PG_FUNCTION_ARGS); extern Datum pg_get_function_result(PG_FUNCTION_ARGS); extern char *deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit); +extern List *deparse_context_for_remotequery(const char *aliasname, Oid relid); +#ifdef PGXC extern List *deparse_context_for(const char *aliasname, Oid relid); +#endif extern List *deparse_context_for_plan(Node *plan, Node *outer_plan, List *rtable, List *subplans); extern const char *quote_identifier(const char *ident); |
