summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAshutosh Bapat2012-06-21 05:46:07 +0000
committerAshutosh Bapat2012-06-21 05:46:07 +0000
commit4fab01e60ff70ba4edee688742a5b7ca539494a8 (patch)
tree01a98db722fbd9ccde5f400d0aee22fd01087bd3 /src
parent037ea439d49bee51fe8af01385badf921db1e867 (diff)
Provide projection capability to the RemoteQuery node.
In RemoteQuery node we provide base_tlist as the target list representing the data expected from the datanodes. This provides the scan tuple descriptor. The actual targetlist expected from the RemoteQuery node is saved in scan.plan.targetlist like other scan plans. This serves as the projection list. Rest of the logic to link the scan targetlist and project targetlist, to apply quals is built in ExecScan(). Since RemoteQuery nodes have projection capabilities, we don't need Result nodes above RemoteQuery nodes just to perform projection. ExecRemoteQuery() now uses a template similar to ExecSeqScan(). Since ExecRemoteQuery() takes care of the materialization, we don't need Materialize node above RemoteQuery node.
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/explain.c6
-rw-r--r--src/backend/optimizer/plan/createplan.c135
-rw-r--r--src/backend/optimizer/plan/setrefs.c23
-rw-r--r--src/backend/pgxc/plan/planner.c1
-rw-r--r--src/backend/pgxc/pool/execRemote.c411
-rw-r--r--src/backend/utils/adt/ruleutils.c40
-rw-r--r--src/include/pgxc/execRemote.h2
-rw-r--r--src/test/regress/expected/aggregates.out122
-rw-r--r--src/test/regress/expected/aggregates_1.out122
-rw-r--r--src/test/regress/expected/create_index.out154
-rw-r--r--src/test/regress/expected/inherit.out16
-rw-r--r--src/test/regress/expected/inherit_1.out16
-rw-r--r--src/test/regress/expected/join.out62
-rw-r--r--src/test/regress/expected/join_1.out68
-rw-r--r--src/test/regress/expected/xc_FQS.out528
-rw-r--r--src/test/regress/expected/xc_FQS_join.out62
-rw-r--r--src/test/regress/expected/xc_alter_table.out44
-rw-r--r--src/test/regress/expected/xc_for_update.out230
-rw-r--r--src/test/regress/expected/xc_groupby.out912
-rw-r--r--src/test/regress/expected/xc_having.out304
-rw-r--r--src/test/regress/expected/xc_remote.out152
21 files changed, 1420 insertions, 1990 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 777541efb3..71e8371a71 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -1692,6 +1692,12 @@ ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
objectname = rte->ctename;
objecttag = "CTE Name";
break;
+ case T_RemoteQuery:
+ /* get the object name from RTE itself */
+ Assert(rte->rtekind == RTE_REMOTE_DUMMY);
+ objectname = rte->relname;
+ objecttag = "RemoteQuery name";
+ break;
default:
break;
}
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 6972cd3e53..635afe8257 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -203,11 +203,12 @@ static Plan *prepare_sort_from_pathkeys(PlannerInfo *root,
static Material *make_material(Plan *lefttree);
#ifdef PGXC
-static void findReferencedVars(List *parent_vars, Plan *plan, List **out_tlist, Relids *out_relids);
+static void findReferencedVars(List *parent_vars, RemoteQuery *plan, List **out_tlist, Relids *out_relids);
static void create_remote_clause_expr(PlannerInfo *root, Plan *parent, StringInfo clauses,
List *qual, RemoteQuery *scan);
static void create_remote_expr(PlannerInfo *root, Plan *parent, StringInfo expr,
Node *node, RemoteQuery *scan);
+static RangeTblEntry *make_dummy_remote_rte(char *relname, Alias *alias);
#endif
/*
@@ -731,9 +732,9 @@ static Plan *
create_remotejoin_plan(PlannerInfo *root, JoinPath *best_path, Plan *parent, Plan *outer_plan, Plan *inner_plan)
{
NestLoop *nest_parent;
- RemoteQuery *outer = NULL;
- RemoteQuery *inner = NULL;
ExecNodes *join_exec_nodes;
+ RemoteQuery *outer;
+ RemoteQuery *inner;
if (!enable_remotejoin)
return parent;
@@ -756,22 +757,14 @@ create_remotejoin_plan(PlannerInfo *root, JoinPath *best_path, Plan *parent, Pla
else
nest_parent = (NestLoop *)parent;
- /*
- * Now RemoteQuery subnode is behind Matherial but this may be changed later
- */
- if (IsA(outer_plan, Material) && IsA(outer_plan->lefttree, RemoteQuery))
- outer = (RemoteQuery *) outer_plan->lefttree;
- else if (IsA(outer_plan, RemoteQuery))
- outer = (RemoteQuery *) outer_plan;
-
- if (IsA(inner_plan, Material) && IsA(inner_plan->lefttree, RemoteQuery))
- inner = (RemoteQuery *) inner_plan->lefttree;
- else if (IsA(inner_plan, RemoteQuery))
- inner = (RemoteQuery *) inner_plan;
+ if (!IsA(outer_plan, RemoteQuery) || !IsA(inner_plan, RemoteQuery))
+ return parent;
+ outer = (RemoteQuery *)outer_plan;
+ inner = (RemoteQuery *)inner_plan;
/* check if both the nodes qualify for reduction */
- if (outer && inner && !outer->scan.plan.qual && !inner->scan.plan.qual)
+ if (!outer->scan.plan.qual && !inner->scan.plan.qual)
{
int i;
List *rtable_list = NIL;
@@ -805,8 +798,8 @@ create_remotejoin_plan(PlannerInfo *root, JoinPath *best_path, Plan *parent, Pla
*/
parent_vars = pull_var_clause((Node *)parent->targetlist, PVC_RECURSE_PLACEHOLDERS);
- findReferencedVars(parent_vars, outer_plan, &out_tlist, &out_relids);
- findReferencedVars(parent_vars, inner_plan, &in_tlist, &in_relids);
+ findReferencedVars(parent_vars, outer, &out_tlist, &out_relids);
+ findReferencedVars(parent_vars, inner, &in_tlist, &in_relids);
join_exec_nodes = IsJoinReducible(inner, outer, in_relids, out_relids,
&(nest_parent->join),
@@ -970,33 +963,21 @@ create_remotejoin_plan(PlannerInfo *root, JoinPath *best_path, Plan *parent, Pla
*/
base_tlist = add_to_flat_tlist(NIL, list_concat(out_tlist, in_tlist));
- dummy_rte = makeNode(RangeTblEntry);
- dummy_rte->rtekind = RTE_REMOTE_DUMMY;
-
- /* use a dummy relname... */
- dummy_rte->relname = "__REMOTE_JOIN_QUERY__";
- dummy_rte->eref = makeAlias("__REMOTE_JOIN_QUERY__", colnames);
- /* not sure if we need to set the below explicitly.. */
- dummy_rte->inh = false;
- dummy_rte->inFromCl = false;
- dummy_rte->requiredPerms = 0;
- dummy_rte->checkAsUser = 0;
- dummy_rte->selectedCols = NULL;
- dummy_rte->modifiedCols = NULL;
-
/*
- * Append the dummy range table entry to the range table.
+ * Create and append the dummy range table entry to the range table.
* Note that this modifies the master copy the caller passed us, otherwise
* e.g EXPLAIN VERBOSE will fail to find the rte the Vars built below refer
* to.
*/
+ dummy_rte = make_dummy_remote_rte("__REMOTE_JOIN_QUERY__",
+ makeAlias("__REMOTE_JOIN_QUERY__", colnames));
root->parse->rtable = lappend(root->parse->rtable, dummy_rte);
dummy_rtindex = list_length(root->parse->rtable);
result_plan = &result->scan.plan;
/* Set the join targetlist to the new base_tlist */
- result_plan->targetlist = base_tlist;
+ result_plan->targetlist = parent->targetlist;
result_plan->lefttree = NULL;
result_plan->righttree = NULL;
result->scan.scanrelid = dummy_rtindex;
@@ -1050,7 +1031,7 @@ create_remotejoin_plan(PlannerInfo *root, JoinPath *best_path, Plan *parent, Pla
result_plan->plan_rows = outer_plan->plan_rows;
result_plan->plan_width = outer_plan->plan_width;
- return (Plan *) make_material(result_plan);
+ return (Plan *)result_plan;
}
}
@@ -2577,7 +2558,6 @@ static Plan *
create_remotequery_plan(PlannerInfo *root, Path *best_path,
List *tlist, List *scan_clauses)
{
- Plan *result_node ;
RemoteQuery *scan_plan;
Index scan_relid = best_path->parent->relid;
RangeTblEntry *rte;
@@ -2592,6 +2572,13 @@ create_remotequery_plan(PlannerInfo *root, Path *best_path,
List *rmlist;
List *tvarlist;
bool tlist_is_simple;
+ List *base_tlist; /* the target list representing the
+ * result obtained from datanode
+ */
+ RangeTblEntry *dummy_rte; /* RTE for the remote query node being
+ * added.
+ */
+ Index dummy_rtindex;
Assert(scan_relid > 0);
Assert(best_path->parent->rtekind == RTE_RELATION);
@@ -2665,6 +2652,14 @@ create_remotequery_plan(PlannerInfo *root, Path *best_path,
}
/*
+ * We are going to change the Var nodes in the target list to be sent to the
+ * datanode. We need the original tlist to establish the mapping of result
+ * obtained from the datanode in this plan. It will be saved in
+ * RemoteQuery->base_tlist. So, copy the target list before modifying it
+ */
+ base_tlist = copyObject(query->targetList);
+
+ /*
* Change the varno in Var nodes in the targetlist of the query to be shipped to the
* Datanode to 1, to match the rtable in the query. Do the same for Var
* nodes in quals.
@@ -2755,29 +2750,25 @@ create_remotequery_plan(PlannerInfo *root, Path *best_path,
if (rmlist != NULL)
list_free_deep(rmlist);
- if (tlist_is_simple)
- {
- scan_plan = make_remotequery(tlist, local_scan_clauses, scan_relid);
- result_node = (Plan *) scan_plan;
- }
- else
- {
- /*
- * Use simple tlist for RemoteQuery, and let Result plan handle
- * non-simple target list.
- */
- scan_plan = make_remotequery(add_to_flat_tlist(NIL, copyObject(tvarlist)),
- local_scan_clauses, scan_relid);
- result_node = (Plan *) make_result(root, tlist, NULL, (Plan*) scan_plan);
- }
+ /*
+ * Create and append the dummy range table entry to the range table.
+ * Note that this modifies the master copy the caller passed us, otherwise
+ * e.g EXPLAIN VERBOSE will fail to find the rte the Vars built below refer
+ * to.
+ */
+ dummy_rte = make_dummy_remote_rte(get_rel_name(rte->relid),
+ makeAlias("_REMOTE_TABLE_QUERY_", NIL));
+ root->parse->rtable = lappend(root->parse->rtable, dummy_rte);
+ dummy_rtindex = list_length(root->parse->rtable);
+
+ scan_plan = make_remotequery(tlist, local_scan_clauses, dummy_rtindex);
/* Track if the remote query involves a temporary object */
scan_plan->is_temp = IsTempTable(rte->relid);
-
scan_plan->read_only = (query->commandType == CMD_SELECT && !query->hasForUpdate);
scan_plan->has_row_marks = query->hasForUpdate;
-
scan_plan->sql_statement = sql.data;
+ scan_plan->base_tlist = base_tlist;
scan_plan->exec_nodes = GetRelationNodesByQuals(rte->relid, rtr->rtindex,
query->jointree->quals,
RELATION_ACCESS_READ);
@@ -2789,7 +2780,7 @@ create_remotequery_plan(PlannerInfo *root, Path *best_path,
/* PGXCTODO - get better estimates */
scan_plan->scan.plan.plan_rows = 1000;
- return result_node;
+ return (Plan *)scan_plan;
}
#endif
@@ -5428,9 +5419,6 @@ is_projection_capable_plan(Plan *plan)
case T_Append:
case T_MergeAppend:
case T_RecursiveUnion:
-#ifdef PGXC
- case T_RemoteQuery:
-#endif
return false;
default:
break;
@@ -5451,7 +5439,7 @@ is_projection_capable_plan(Plan *plan)
* also need to be selected..
*/
static void
-findReferencedVars(List *parent_vars, Plan *plan, List **out_tlist, Relids *out_relids)
+findReferencedVars(List *parent_vars, RemoteQuery *plan, List **out_tlist, Relids *out_relids)
{
List *vars;
Relids relids = NULL;
@@ -5459,7 +5447,7 @@ findReferencedVars(List *parent_vars, Plan *plan, List **out_tlist, Relids *out_
ListCell *l;
/* Pull vars from both the targetlist and the clauses attached to this plan */
- vars = pull_var_clause((Node *)plan->targetlist, PVC_REJECT_PLACEHOLDERS);
+ vars = pull_var_clause((Node *)plan->base_tlist, PVC_REJECT_PLACEHOLDERS);
foreach(l, vars)
{
@@ -5473,7 +5461,7 @@ findReferencedVars(List *parent_vars, Plan *plan, List **out_tlist, Relids *out_
}
/* Now consider the local quals */
- vars = pull_var_clause((Node *)plan->qual, PVC_REJECT_PLACEHOLDERS);
+ vars = pull_var_clause((Node *)plan->scan.plan.qual, PVC_REJECT_PLACEHOLDERS);
foreach(l, vars)
{
@@ -6174,7 +6162,7 @@ create_remotegrouping_plan(PlannerInfo *root, Plan *local_plan)
/* find all the relations referenced by targetlist of Grouping node */
temp_vars = pull_var_clause((Node *)local_plan->targetlist,
PVC_REJECT_PLACEHOLDERS);
- findReferencedVars(temp_vars, (Plan *)remote_scan, &temp_vartlist, &in_relids);
+ findReferencedVars(temp_vars, remote_scan, &temp_vartlist, &in_relids);
/*
* process the targetlist of the grouping plan, also construct the
@@ -6328,13 +6316,8 @@ create_remotegrouping_plan(PlannerInfo *root, Plan *local_plan)
* descriptor for the result of this query from the base_tlist (targetlist
* we used to generate the remote node query).
*/
- dummy_rte = makeNode(RangeTblEntry);
- dummy_rte->rtekind = RTE_REMOTE_DUMMY;
-
- /* Use a dummy relname... */
- dummy_rte->relname = "__REMOTE_GROUP_QUERY__";
- dummy_rte->eref = makeAlias("__REMOTE_GROUP_QUERY__", NIL);
-
+ dummy_rte = make_dummy_remote_rte("__REMOTE_GROUP_QUERY__",
+ makeAlias("__REMOTE_GROUP_QUERY__", NIL));
/* Rest will be zeroed out in makeNode() */
root->parse->rtable = lappend(root->parse->rtable, dummy_rte);
dummy_rtindex = list_length(root->parse->rtable);
@@ -6352,6 +6335,7 @@ create_remotegrouping_plan(PlannerInfo *root, Plan *local_plan)
/* set_plan_refs needs this later */
remote_group->read_only = (query->commandType == CMD_SELECT && !query->hasForUpdate);
remote_group->has_row_marks = query->hasForUpdate;
+ remote_group->base_tlist = base_tlist;
/* we actually need not worry about costs since this is the final plan */
remote_group_plan->startup_cost = remote_scan->scan.plan.startup_cost;
@@ -6364,7 +6348,7 @@ create_remotegrouping_plan(PlannerInfo *root, Plan *local_plan)
* Materialization is always needed for RemoteQuery in case we need to restart
* the scan.
*/
- local_plan->lefttree = (Plan *) make_material(remote_group_plan);
+ local_plan->lefttree = remote_group_plan;
local_plan->qual = local_qual;
/* indicate that we should apply collection function directly */
if (IsA(local_plan, Agg))
@@ -6907,4 +6891,17 @@ pgxc_build_rowmark_entries(List *rowMarks, List *rtable, Oid *types, int preppar
return newtypes;
}
+
+static RangeTblEntry *
+make_dummy_remote_rte(char *relname, Alias *alias)
+{
+ RangeTblEntry *dummy_rte = makeNode(RangeTblEntry);
+ dummy_rte->rtekind = RTE_REMOTE_DUMMY;
+
+ /* use a dummy relname... */
+ dummy_rte->relname = relname;
+ dummy_rte->eref = alias;
+
+ return dummy_rte;
+}
#endif
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index a9c1153977..d8f83aada0 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -428,23 +428,19 @@ set_plan_refs(PlannerGlobal *glob, Plan *plan, int rtoffset)
{
RemoteQuery *splan = (RemoteQuery *) plan;
- splan->scan.scanrelid += rtoffset;
-
/*
* If base_tlist is set, it means that we have a reduced remote
* query plan. So need to set the var references accordingly.
*/
if (splan->base_tlist)
- {
set_remote_references(glob, splan, rtoffset);
- }
- else
- {
- splan->scan.plan.targetlist =
- fix_scan_list(glob, splan->scan.plan.targetlist, rtoffset);
- splan->scan.plan.qual =
- fix_scan_list(glob, splan->scan.plan.qual, rtoffset);
- }
+ splan->scan.plan.targetlist =
+ fix_scan_list(glob, splan->scan.plan.targetlist, rtoffset);
+ splan->scan.plan.qual =
+ fix_scan_list(glob, splan->scan.plan.qual, rtoffset);
+ splan->base_tlist =
+ fix_scan_list(glob, splan->base_tlist, rtoffset);
+ splan->scan.scanrelid += rtoffset;
}
break;
#endif
@@ -1977,8 +1973,6 @@ fix_remote_expr_mutator(Node *node, fix_remote_expr_context *context)
return (Node *) newvar;
}
- fix_expr_common(context->glob, node);
-
return expression_tree_mutator(node, fix_remote_expr_mutator, context);
}
@@ -1999,9 +1993,6 @@ set_remote_references(PlannerGlobal *glob, RemoteQuery *rscan, int rtoffset)
if (!rscan->base_tlist)
return;
- /* We have incremented reduce_level wherever we created reduced plans. */
- Assert(rscan->reduce_level > 0);
-
base_itlist = build_tlist_index(rscan->base_tlist);
/* All remotescan plans have tlist, and quals */
diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c
index 0a2831afda..12b65f6226 100644
--- a/src/backend/pgxc/plan/planner.c
+++ b/src/backend/pgxc/plan/planner.c
@@ -715,6 +715,7 @@ pgxc_FQS_create_remote_plan(Query *query, ExecNodes *exec_nodes, bool is_exec_di
query->rtable = lappend(query->rtable, dummy_rte);
query_step->scan.scanrelid = list_length(query->rtable);
query_step->scan.plan.targetlist = query->targetList;
+ query_step->base_tlist = query->targetList;
return query_step;
}
diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c
index c8aef7cbaf..961b7bfd71 100644
--- a/src/backend/pgxc/pool/execRemote.c
+++ b/src/backend/pgxc/pool/execRemote.c
@@ -6,7 +6,7 @@
*
*
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
- * Portions Copyright (c) 2010-2012 Postgres-XC Development Group
+ * Portions Copyright (c) 2010-2012 Nippon Telegraph and Telephone Corporation
*
* IDENTIFICATION
* $$
@@ -142,7 +142,9 @@ static int pgxc_get_connections(PGXCNodeHandle *connections[], int size, List *c
static bool pgxc_start_command_on_connection(PGXCNodeHandle *connection,
RemoteQueryState *remotestate, Snapshot snapshot);
-static TupleTableSlot * RemoteQueryNext(RemoteQueryState *node);
+static TupleTableSlot * RemoteQueryNext(ScanState *node);
+static bool RemoteQueryRecheck(RemoteQueryState *node, TupleTableSlot *slot);
+
static char *generate_begin_command(void);
static bool pgxc_node_remote_prepare(char *prepareGID);
@@ -2467,6 +2469,7 @@ RemoteQueryState *
ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags)
{
RemoteQueryState *remotestate;
+ TupleDesc scan_type;
/* RemoteQuery node is the leaf node in the plan tree, just like seqscan */
Assert(innerPlan(node) == NULL);
@@ -2476,6 +2479,17 @@ ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags)
remotestate->ss.ps.plan = (Plan *) node;
remotestate->ss.ps.state = estate;
+ /*
+ * Miscellaneous initialisation
+ *
+ * create expression context for node
+ */
+ ExecAssignExprContext(estate, &remotestate->ss.ps);
+
+ /* Initialise child expressions */
+ remotestate->ss.ps.targetlist = (List *)
+ ExecInitExpr((Expr *) node->scan.plan.targetlist,
+ (PlanState *) remotestate);
remotestate->ss.ps.qual = (List *)
ExecInitExpr((Expr *) node->scan.plan.qual,
(PlanState *) remotestate);
@@ -2493,36 +2507,9 @@ ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags)
remotestate->tuplestorestate = NULL;
ExecInitResultTupleSlot(estate, &remotestate->ss.ps);
- if (node->scan.plan.targetlist)
- {
- TupleDesc typeInfo = ExecCleanTypeFromTL(node->scan.plan.targetlist, false);
- ExecSetSlotDescriptor(remotestate->ss.ps.ps_ResultTupleSlot, typeInfo);
- }
- else
- {
- /* In case there is no target list, force its creation */
- ExecAssignResultTypeFromTL(&remotestate->ss.ps);
- }
-
ExecInitScanTupleSlot(estate, &remotestate->ss);
-
- /*
- * Is it a single table scan ? If yes, collect the varattnos of the
- * targetlist, needed later for applying quals.
- */
- if (getrelid(node->scan.scanrelid, estate->es_range_table) != InvalidOid)
- {
- Relation rel = ExecOpenScanRelation(estate, node->scan.scanrelid);
- remotestate->fulltupleslot = ExecInitExtraTupleSlot(estate);
- ExecSetSlotDescriptor(remotestate->fulltupleslot,
- CreateTupleDescCopy(RelationGetDescr(rel)));
- ExecCloseScanRelation(rel);
-
- if (node->scan.plan.targetlist)
- remotestate->tlist_vars =
- pull_var_clause((Node*)node->scan.plan.targetlist, PVC_REJECT_PLACEHOLDERS);
-
- }
+ scan_type = ExecTypeFromTL(node->base_tlist, false);
+ ExecAssignScanType(&remotestate->ss, scan_type);
remotestate->ss.ps.ps_TupFromTlist = false;
@@ -2537,64 +2524,15 @@ ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags)
&remotestate->paramval_data);
}
- /* We need expression context to evaluate */
- if (node->exec_nodes && node->exec_nodes->en_expr)
- ExecAssignExprContext(estate, &remotestate->ss.ps);
- else if (remotestate->ss.ps.qual)
- ExecAssignExprContext(estate, &remotestate->ss.ps);
+ /*
+ * Initialize result tuple type and projection info.
+ */
+ ExecAssignResultTypeFromTL(&remotestate->ss.ps);
+ ExecAssignScanProjectionInfo(&remotestate->ss);
return remotestate;
}
-
-static void
-copy_slot(RemoteQueryState *node, TupleTableSlot *src, TupleTableSlot *dst)
-{
- if (src->tts_dataRow
- && dst->tts_tupleDescriptor->natts == src->tts_tupleDescriptor->natts)
- {
- if (src->tts_mcxt == dst->tts_mcxt)
- {
- /* now dst slot controls the backing message */
- ExecStoreDataRowTuple(src->tts_dataRow, src->tts_dataLen, dst,
- src->tts_shouldFreeRow);
- src->tts_shouldFreeRow = false;
- }
- else
- {
- /* have to make a copy */
- MemoryContext oldcontext = MemoryContextSwitchTo(dst->tts_mcxt);
- int len = src->tts_dataLen;
- char *msg = (char *) palloc(len);
-
- memcpy(msg, src->tts_dataRow, len);
- ExecStoreDataRowTuple(msg, len, dst, true);
- MemoryContextSwitchTo(oldcontext);
- }
- }
- else
- {
- int i;
-
- /*
- * Datanode may be sending junk columns which are always at the end,
- * but it must not be shorter then result slot.
- */
- Assert(dst->tts_tupleDescriptor->natts <= src->tts_tupleDescriptor->natts);
- ExecClearTuple(dst);
- slot_getallattrs(src);
- /*
- * PGXCTODO revisit: if it is correct to copy Datums using assignment?
- */
- for (i = 0; i < dst->tts_tupleDescriptor->natts; i++)
- {
- dst->tts_values[i] = src->tts_values[i];
- dst->tts_isnull[i] = src->tts_isnull[i];
- }
- ExecStoreVirtualTuple(dst);
- }
-}
-
/*
* Get Node connections depending on the connection type:
* Datanodes Only, Coordinators only or both types
@@ -3053,6 +2991,16 @@ do_query(RemoteQueryState *node)
*/
break;
}
+ else
+ {
+ /*
+ * RemoteQuery node doesn't support backward scan, so
+ * randomAccess is false, neither we want this tuple store
+ * persist across transactions.
+ */
+ node->tuplestorestate = tuplestore_begin_heap(false, false, work_mem);
+ tuplestore_set_eflags(node->tuplestorestate, node->eflags);
+ }
}
else if (res == RESPONSE_DATAROW)
{
@@ -3082,100 +3030,6 @@ do_query(RemoteQueryState *node)
}
/*
- * apply_qual
- * Applies the qual of the query, and returns the same slot if the qual returns
- * true, else returns NULL.
- *
- * If it is a single relation scan, the quals attnos refer to the
- * attribute no. of the actual table descriptor. So when they are applied
- * to a tuple slot, the tuple slot descriptor also should match the table desc.
- * But the result slot corresponds to the order of target list which need not
- * coincide with the order of table attributes. So we need to rearrange the
- * values from result slot into an intermediate slot
- * (RemoteQueryState->fulltupleslot) and then apply the quals on
- * fulltupleslot. And to rearrange the values, we need to save the
- * targetlist vars to be stored (in RemoteQueryState->tlist_vars).
- *
- * If it is not a single table scan, it should be a reduced scan, for e.g.
- * reduced remote join. In this case, the qual references are already
- * adjusted (set_remote_references) according to their position in
- * targetlist, so they can be safely applied to the resultslot without the
- * need of an intermediate slot. So in this scenario, fulltupslot is NULL.
- */
-static TupleTableSlot *
-apply_qual(TupleTableSlot *slot, RemoteQueryState *node)
-{
- List *qual = node->ss.ps.qual;
- TupleTableSlot *fulltupslot = node->fulltupleslot;
- ExprContext *econtext = node->ss.ps.ps_ExprContext;
-
- if (!qual)
- return slot;
-
- if (fulltupslot && node->tlist_vars)
- {
- int attindex;
- int attno;
- List *tlist_vars = node->tlist_vars;
- ListCell *l;
-
- ExecClearTuple(fulltupslot);
-
- /*
- * Fill all the columns of the virtual tuple with nulls because the
- * tlist_varattnos might be only a subset of all the table attributes,
- * so the unassigned attributes should be NULL.
- */
- MemSet(fulltupslot->tts_values, 0,
- fulltupslot->tts_tupleDescriptor->natts * sizeof(Datum));
- memset(fulltupslot->tts_isnull, true,
- fulltupslot->tts_tupleDescriptor->natts * sizeof(bool));
-
- /*
- * For each var in the target list, store its value in the
- * appropriate position in the intermediate tuple slot.
- */
- attindex = 1;
- foreach(l, tlist_vars)
- {
- Var *var = lfirst(l);
- attno = var->varattno;
- Assert(attno <= fulltupslot->tts_tupleDescriptor->natts);
-
- /*
- * Currently we do not handle sys attributes in quals, so do not
- * bother about storing sys attribute values.
- * PGXCTODO : Handle sys attributes in quals. Currently
- * slot_getattr() returns error when a non-shippable clause
- * refers to system column like ctid :
- * "cannot extract system attribute from virtual tuple".
- */
- if (attno >= 1)
- {
- fulltupslot->tts_values[attno - 1] =
- slot_getattr(slot, attindex,
- &fulltupslot->tts_isnull[attno - 1]);
- }
- attindex++;
- }
-
- ExecStoreVirtualTuple(fulltupslot);
- slot = fulltupslot;
- }
-
- econtext->ecxt_scantuple = slot;
-
- /*
- * Now that we have made sure the slot values are in order of table
- * descriptor, go ahead and apply the qual.
- */
- if (!ExecQual(qual, econtext, false))
- return NULL;
- else
- return slot;
-}
-
-/*
* ExecRemoteQuery
* Wrapper around the main RemoteQueryNext() function. This
* wrapper provides materialization of the result returned by
@@ -3185,112 +3039,23 @@ apply_qual(TupleTableSlot *slot, RemoteQueryState *node)
TupleTableSlot *
ExecRemoteQuery(RemoteQueryState *node)
{
- TupleTableSlot *resultslot = node->ss.ps.ps_ResultTupleSlot;
- Tuplestorestate *tuplestorestate;
- bool eof_tuplestore;
- bool forward = ScanDirectionIsForward(node->ss.ps.state->es_direction);
- TupleTableSlot *slot;
-
- /*
- * If sorting is needed, then tuplesortstate takes care of
- * materialization
- */
- if (((RemoteQuery *) node->ss.ps.plan)->sort)
- return RemoteQueryNext(node);
-
-
- tuplestorestate = node->tuplestorestate;
-
- if (tuplestorestate == NULL)
- {
- tuplestorestate = tuplestore_begin_heap(true, false, work_mem);
- tuplestore_set_eflags(tuplestorestate, node->eflags);
- node->tuplestorestate = tuplestorestate;
- }
-
- /*
- * If we are not at the end of the tuplestore, or are going backwards, try
- * to fetch a tuple from tuplestore.
- */
- eof_tuplestore = (tuplestorestate == NULL) ||
- tuplestore_ateof(tuplestorestate);
-
- if (!forward && eof_tuplestore)
- {
- if (!node->eof_underlying)
- {
- /*
- * When reversing direction at tuplestore EOF, the first
- * gettupleslot call will fetch the last-added tuple; but we want
- * to return the one before that, if possible. So do an extra
- * fetch.
- */
- if (!tuplestore_advance(tuplestorestate, forward))
- return NULL; /* the tuplestore must be empty */
- }
- eof_tuplestore = false;
- }
-
- /*
- * If we can fetch another tuple from the tuplestore, return it.
- */
- slot = node->ss.ps.ps_ResultTupleSlot;
- if (!eof_tuplestore)
- {
- /* Look for the first tuple that matches qual */
- while (tuplestore_gettupleslot(tuplestorestate, forward, false, slot))
- {
- if (apply_qual(slot, node))
- return slot;
- }
- /* Not found */
- if (forward)
- eof_tuplestore = true;
- }
-
+ return ExecScan(&(node->ss),
+ (ExecScanAccessMtd) RemoteQueryNext,
+ (ExecScanRecheckMtd) RemoteQueryRecheck);
+}
+/*
+ * RemoteQueryRecheck -- remote query routine to recheck a tuple in EvalPlanQual
+ */
+static bool
+RemoteQueryRecheck(RemoteQueryState *node, TupleTableSlot *slot)
+{
/*
- * If tuplestore has reached its end but the underlying RemoteQueryNext() hasn't
- * finished yet, try to fetch another row.
+ * Note that unlike IndexScan, RemoteQueryScan never use keys in heap_beginscan
+ * (and this is very bad) - so, here we do not check are keys ok or not.
*/
- if (eof_tuplestore && !node->eof_underlying)
- {
- TupleTableSlot *outerslot;
-
- while (1)
- {
- /*
- * We can only get here with forward==true, so no need to worry about
- * which direction the subplan will go.
- */
- outerslot = RemoteQueryNext(node);
- if (TupIsNull(outerslot))
- {
- node->eof_underlying = true;
- return NULL;
- }
-
- /*
- * Append a copy of the returned tuple to tuplestore. NOTE: because
- * the tuplestore is certainly in EOF state, its read position will
- * move forward over the added tuple. This is what we want.
- */
- if (tuplestorestate)
- tuplestore_puttupleslot(tuplestorestate, outerslot);
-
- /*
- * If qual returns true, return the fetched tuple, else continue for
- * next tuple
- */
- if (apply_qual(outerslot, node))
- return outerslot;
- }
-
- }
-
- return ExecClearTuple(resultslot);
+ return true;
}
-
/*
* Execute step of PGXC plan.
* The step specifies a command to be executed on specified nodes.
@@ -3302,13 +3067,10 @@ ExecRemoteQuery(RemoteQueryState *node)
* The function returns at most one tuple per invocation.
*/
static TupleTableSlot *
-RemoteQueryNext(RemoteQueryState *node)
+RemoteQueryNext(ScanState *scan_node)
{
- TupleTableSlot *resultslot = node->ss.ps.ps_ResultTupleSlot;
- TupleTableSlot *scanslot = node->ss.ss_ScanTupleSlot;
- bool have_tuple = false;
- List *qual = node->ss.ps.qual;
- ExprContext *econtext = node->ss.ps.ps_ExprContext;
+ RemoteQueryState *node = (RemoteQueryState *)scan_node;
+ TupleTableSlot *scanslot = scan_node->ss_ScanTupleSlot;
if (!node->query_Done)
{
@@ -3327,47 +3089,62 @@ RemoteQueryNext(RemoteQueryState *node)
pfree_pgxc_all_handles(all_dn_handles);
}
+ /* We can't have both tuplesortstate and tuplestorestate */
+ Assert(!(node->tuplesortstate && node->tuplestorestate));
+
if (node->tuplesortstate)
+ tuplesort_gettupleslot((Tuplesortstate *) node->tuplesortstate,
+ true, scanslot);
+ else if(node->tuplestorestate)
{
- while (tuplesort_gettupleslot((Tuplesortstate *) node->tuplesortstate,
- true, scanslot))
+ /*
+ * If we are not at the end of the tuplestore, try
+ * to fetch a tuple from tuplestore.
+ */
+ Tuplestorestate *tuplestorestate = node->tuplestorestate;
+ bool eof_tuplestore = tuplestore_ateof(tuplestorestate);
+
+ /*
+ * If we can fetch another tuple from the tuplestore, return it.
+ */
+ if (!eof_tuplestore)
{
- if (apply_qual(scanslot, node))
- have_tuple = true;
- else
+ /* RemoteQuery node doesn't support backward scans */
+ if(!tuplestore_gettupleslot(tuplestorestate, true, false, scanslot))
+ eof_tuplestore = true;
+ }
+
+ if (eof_tuplestore && !node->eof_underlying)
+ {
+ /*
+ * If tuplestore has reached its end but the underlying RemoteQueryNext() hasn't
+ * finished yet, try to fetch another row.
+ */
+ if (FetchTuple(node, scanslot))
{
- have_tuple = false;
- continue;
+ /*
+ * Append a copy of the returned tuple to tuplestore. NOTE: because
+ * the tuplestore is certainly in EOF state, its read position will
+ * move forward over the added tuple. This is what we want.
+ */
+ if (tuplestorestate && !TupIsNull(scanslot))
+ tuplestore_puttupleslot(tuplestorestate, scanslot);
}
- copy_slot(node, scanslot, resultslot);
- break;
+ else
+ node->eof_underlying = true;
}
- if (!have_tuple)
- ExecClearTuple(resultslot);
+
+ if (eof_tuplestore && node->eof_underlying)
+ ExecClearTuple(scanslot);
}
+ /* No tuple store whatsoever, no result from the datanode */
else
- {
- if (FetchTuple(node, scanslot) && !TupIsNull(scanslot))
- {
- if (qual)
- econtext->ecxt_scantuple = scanslot;
- copy_slot(node, scanslot, resultslot);
- }
- else
- ExecClearTuple(resultslot);
- }
+ ExecClearTuple(scanslot);
+
/* report error if any */
pgxc_node_report_error(node);
- /*
- * While we are emitting rows we ignore outer plan
- */
- if (!TupIsNull(resultslot))
- return resultslot;
- /*
- * OK, we have nothing to return, so return NULL
- */
- return NULL;
+ return scanslot;
}
/*
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 8864052996..945b8ba368 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -55,6 +55,10 @@
#include "parser/parse_type.h"
#include "parser/parser.h"
#include "parser/parsetree.h"
+#ifdef PGXC
+#include "pgxc/pgxc.h"
+#include "pgxc/planner.h"
+#endif
#include "rewrite/rewriteHandler.h"
#include "rewrite/rewriteManip.h"
#include "rewrite/rewriteSupport.h"
@@ -66,9 +70,6 @@
#include "utils/syscache.h"
#include "utils/typcache.h"
#include "utils/xml.h"
-#ifdef PGXC
-#include "pgxc/pgxc.h"
-#endif
/* ----------
* Pretty formatting constants
@@ -4379,6 +4380,39 @@ get_variable(Var *var, int levelsup, bool showstar, deparse_context *context)
return NULL;
}
+#ifdef PGXC
+ if (rte->rtekind == RTE_REMOTE_DUMMY &&
+ attnum > list_length(rte->eref->colnames) &&
+ dpns->planstate)
+ {
+ TargetEntry *tle;
+ RemoteQuery *rqplan;
+ Assert(IsA(dpns->planstate, RemoteQueryState));
+ Assert(netlevelsup == 0);
+
+ /*
+ * Get the expression representing the given Var from base_tlist of the
+ * RemoteQuery
+ */
+ rqplan = (RemoteQuery *)dpns->planstate->plan;
+ Assert(IsA(rqplan, RemoteQuery));
+ tle = get_tle_by_resno(rqplan->base_tlist, var->varattno);
+ if (!tle)
+ elog(ERROR, "bogus varattno for remotequery var: %d", var->varattno);
+ /*
+ * Force parentheses because our caller probably assumed a Var is a
+ * simple expression.
+ */
+ if (!IsA(tle->expr, Var))
+ appendStringInfoChar(buf, '(');
+ get_rule_expr((Node *) tle->expr, context, true);
+ if (!IsA(tle->expr, Var))
+ appendStringInfoChar(buf, ')');
+
+ return NULL;
+ }
+#endif /* PGXC */
+
/* Identify names to use */
schemaname = NULL; /* default assumptions */
refname = rte->eref->aliasname;
diff --git a/src/include/pgxc/execRemote.h b/src/include/pgxc/execRemote.h
index 2241a50e8f..4992403c53 100644
--- a/src/include/pgxc/execRemote.h
+++ b/src/include/pgxc/execRemote.h
@@ -124,8 +124,6 @@ typedef struct RemoteQueryState
int eflags; /* capability flags to pass to tuplestore */
bool eof_underlying; /* reached end of underlying plan? */
Tuplestorestate *tuplestorestate;
- List *tlist_vars; /* Vars extracted from target list */
- TupleTableSlot *fulltupleslot; /* intermediate slot for applying quals */
} RemoteQueryState;
diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out
index dd20688519..06b8fdd644 100644
--- a/src/test/regress/expected/aggregates.out
+++ b/src/test/regress/expected/aggregates.out
@@ -452,12 +452,11 @@ analyze tenk1; -- ensure we get consistent plans here
-- Basic cases
explain (costs off, nodes off)
select min(unique1) from tenk1;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select min(unique1) from tenk1;
min
@@ -467,12 +466,11 @@ select min(unique1) from tenk1;
explain (costs off, nodes off)
select max(unique1) from tenk1;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1;
max
@@ -482,12 +480,11 @@ select max(unique1) from tenk1;
explain (costs off, nodes off)
select max(unique1) from tenk1 where unique1 < 42;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1 where unique1 < 42;
max
@@ -497,12 +494,11 @@ select max(unique1) from tenk1 where unique1 < 42;
explain (costs off, nodes off)
select max(unique1) from tenk1 where unique1 > 42;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1 where unique1 > 42;
max
@@ -512,12 +508,11 @@ select max(unique1) from tenk1 where unique1 > 42;
explain (costs off, nodes off)
select max(unique1) from tenk1 where unique1 > 42000;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1 where unique1 > 42000;
max
@@ -528,12 +523,11 @@ select max(unique1) from tenk1 where unique1 > 42000;
-- multi-column index (uses tenk1_thous_tenthous)
explain (costs off, nodes off)
select max(tenthous) from tenk1 where thousand = 33;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(tenthous) from tenk1 where thousand = 33;
max
@@ -543,12 +537,11 @@ select max(tenthous) from tenk1 where thousand = 33;
explain (costs off, nodes off)
select min(tenthous) from tenk1 where thousand = 33;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select min(tenthous) from tenk1 where thousand = 33;
min
@@ -560,15 +553,14 @@ select min(tenthous) from tenk1 where thousand = 33;
explain (costs off, nodes off)
select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt
from int4_tbl;
- QUERY PLAN
-------------------------------------------------------------
- Result
- -> Data Node Scan on int4_tbl
+ QUERY PLAN
+--------------------------------------------------------------
+ Data Node Scan on int4_tbl "_REMOTE_TABLE_QUERY_"
SubPlan 1
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
Coordinator quals: (unique1 > int4_tbl.f1)
-(6 rows)
+(5 rows)
select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt
from int4_tbl
@@ -585,11 +577,11 @@ order by f1;
-- check some cases that were handled incorrectly in 8.3.0
explain (costs off, nodes off)
select distinct max(unique2) from tenk1;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
HashAggregate
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(3 rows)
select distinct max(unique2) from tenk1;
@@ -600,12 +592,12 @@ select distinct max(unique2) from tenk1;
explain (costs off, nodes off)
select max(unique2) from tenk1 order by 1;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
- Sort Key: (max(unique2))
+ Sort Key: (max(tenk1.unique2))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2) from tenk1 order by 1;
@@ -616,12 +608,12 @@ select max(unique2) from tenk1 order by 1;
explain (costs off, nodes off)
select max(unique2) from tenk1 order by max(unique2);
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
- Sort Key: (max(unique2))
+ Sort Key: (max(tenk1.unique2))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2) from tenk1 order by max(unique2);
@@ -632,12 +624,12 @@ select max(unique2) from tenk1 order by max(unique2);
explain (costs off, nodes off)
select max(unique2) from tenk1 order by max(unique2)+1;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
- Sort Key: ((max(unique2) + 1))
+ Sort Key: ((max(tenk1.unique2) + 1))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2) from tenk1 order by max(unique2)+1;
@@ -648,12 +640,12 @@ select max(unique2) from tenk1 order by max(unique2)+1;
explain (costs off, nodes off)
select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
Sort Key: (generate_series(1, 3))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
@@ -679,14 +671,14 @@ insert into minmaxtest2 values(15), (16);
insert into minmaxtest3 values(17), (18);
explain (costs off, nodes off)
select min(f1), max(f1) from minmaxtest;
- QUERY PLAN
-------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Aggregate
-> Append
- -> Data Node Scan on minmaxtest
- -> Data Node Scan on minmaxtest
- -> Data Node Scan on minmaxtest
- -> Data Node Scan on minmaxtest
+ -> Data Node Scan on minmaxtest "_REMOTE_TABLE_QUERY_"
+ -> Data Node Scan on minmaxtest1 "_REMOTE_TABLE_QUERY_"
+ -> Data Node Scan on minmaxtest2 "_REMOTE_TABLE_QUERY_"
+ -> Data Node Scan on minmaxtest3 "_REMOTE_TABLE_QUERY_"
(6 rows)
select min(f1), max(f1) from minmaxtest;
diff --git a/src/test/regress/expected/aggregates_1.out b/src/test/regress/expected/aggregates_1.out
index 1300bcb4b8..86b3e7ca1e 100644
--- a/src/test/regress/expected/aggregates_1.out
+++ b/src/test/regress/expected/aggregates_1.out
@@ -454,12 +454,11 @@ analyze tenk1; -- ensure we get consistent plans here
-- Basic cases
explain (costs off, nodes off)
select min(unique1) from tenk1;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select min(unique1) from tenk1;
min
@@ -469,12 +468,11 @@ select min(unique1) from tenk1;
explain (costs off, nodes off)
select max(unique1) from tenk1;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1;
max
@@ -484,12 +482,11 @@ select max(unique1) from tenk1;
explain (costs off, nodes off)
select max(unique1) from tenk1 where unique1 < 42;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1 where unique1 < 42;
max
@@ -499,12 +496,11 @@ select max(unique1) from tenk1 where unique1 < 42;
explain (costs off, nodes off)
select max(unique1) from tenk1 where unique1 > 42;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1 where unique1 > 42;
max
@@ -514,12 +510,11 @@ select max(unique1) from tenk1 where unique1 > 42;
explain (costs off, nodes off)
select max(unique1) from tenk1 where unique1 > 42000;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(unique1) from tenk1 where unique1 > 42000;
max
@@ -530,12 +525,11 @@ select max(unique1) from tenk1 where unique1 > 42000;
-- multi-column index (uses tenk1_thous_tenthous)
explain (costs off, nodes off)
select max(tenthous) from tenk1 where thousand = 33;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select max(tenthous) from tenk1 where thousand = 33;
max
@@ -545,12 +539,11 @@ select max(tenthous) from tenk1 where thousand = 33;
explain (costs off, nodes off)
select min(tenthous) from tenk1 where thousand = 33;
- QUERY PLAN
---------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------
Aggregate
- -> Materialize
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
-(3 rows)
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
+(2 rows)
select min(tenthous) from tenk1 where thousand = 33;
min
@@ -562,15 +555,14 @@ select min(tenthous) from tenk1 where thousand = 33;
explain (costs off, nodes off)
select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt
from int4_tbl;
- QUERY PLAN
-------------------------------------------------------------
- Result
- -> Data Node Scan on int4_tbl
+ QUERY PLAN
+--------------------------------------------------------------
+ Data Node Scan on int4_tbl "_REMOTE_TABLE_QUERY_"
SubPlan 1
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
Coordinator quals: (unique1 > int4_tbl.f1)
-(6 rows)
+(5 rows)
select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt
from int4_tbl
@@ -587,11 +579,11 @@ order by f1;
-- check some cases that were handled incorrectly in 8.3.0
explain (costs off, nodes off)
select distinct max(unique2) from tenk1;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
HashAggregate
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(3 rows)
select distinct max(unique2) from tenk1;
@@ -602,12 +594,12 @@ select distinct max(unique2) from tenk1;
explain (costs off, nodes off)
select max(unique2) from tenk1 order by 1;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
- Sort Key: (max(unique2))
+ Sort Key: (max(tenk1.unique2))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2) from tenk1 order by 1;
@@ -618,12 +610,12 @@ select max(unique2) from tenk1 order by 1;
explain (costs off, nodes off)
select max(unique2) from tenk1 order by max(unique2);
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
- Sort Key: (max(unique2))
+ Sort Key: (max(tenk1.unique2))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2) from tenk1 order by max(unique2);
@@ -634,12 +626,12 @@ select max(unique2) from tenk1 order by max(unique2);
explain (costs off, nodes off)
select max(unique2) from tenk1 order by max(unique2)+1;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
- Sort Key: ((max(unique2) + 1))
+ Sort Key: ((max(tenk1.unique2) + 1))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2) from tenk1 order by max(unique2)+1;
@@ -650,12 +642,12 @@ select max(unique2) from tenk1 order by max(unique2)+1;
explain (costs off, nodes off)
select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
- QUERY PLAN
--------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Sort
Sort Key: (generate_series(1, 3))
-> Aggregate
- -> Data Node Scan on tenk1
+ -> Data Node Scan on tenk1 "_REMOTE_TABLE_QUERY_"
(4 rows)
select max(unique2), generate_series(1,3) as g from tenk1 order by g desc;
@@ -681,14 +673,14 @@ insert into minmaxtest2 values(15), (16);
insert into minmaxtest3 values(17), (18);
explain (costs off, nodes off)
select min(f1), max(f1) from minmaxtest;
- QUERY PLAN
-------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Aggregate
-> Append
- -> Data Node Scan on minmaxtest
- -> Data Node Scan on minmaxtest
- -> Data Node Scan on minmaxtest
- -> Data Node Scan on minmaxtest
+ -> Data Node Scan on minmaxtest "_REMOTE_TABLE_QUERY_"
+ -> Data Node Scan on minmaxtest1 "_REMOTE_TABLE_QUERY_"
+ -> Data Node Scan on minmaxtest2 "_REMOTE_TABLE_QUERY_"
+ -> Data Node Scan on minmaxtest3 "_REMOTE_TABLE_QUERY_"
(6 rows)
select min(f1), max(f1) from minmaxtest;
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index bc248685b5..17aae038a3 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -215,17 +215,15 @@ EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY (home_base[0])[0];
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------
Sort
- Output: home_base, ((home_base[0])[0])
+ Output: fast_emp4000.home_base, ((fast_emp4000.home_base[0])[0])
Sort Key: ((fast_emp4000.home_base[0])[0])
- -> Result
- Output: home_base, (home_base[0])[0]
- -> Data Node Scan on fast_emp4000
- Output: home_base
- Remote query: SELECT home_base FROM ONLY fast_emp4000 WHERE (home_base @ '(2000,1000),(200,200)'::box)
-(8 rows)
+ -> Data Node Scan on fast_emp4000 "_REMOTE_TABLE_QUERY_"
+ Output: fast_emp4000.home_base, (fast_emp4000.home_base[0])[0]
+ Remote query: SELECT home_base FROM ONLY fast_emp4000 WHERE (home_base @ '(2000,1000),(200,200)'::box)
+(6 rows)
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
@@ -238,16 +236,14 @@ SELECT * FROM fast_emp4000
EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*)
- Remote query: SELECT count(*) FROM (SELECT * FROM ONLY fast_emp4000 WHERE (home_base && '(1000,1000),(0,0)'::box)) group_1
-(7 rows)
+ Remote query: SELECT count(*) FROM (SELECT * FROM ONLY fast_emp4000 WHERE (home_base && '(1000,1000),(0,0)'::box)) group_1
+(5 rows)
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
count
@@ -257,16 +253,14 @@ SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*)
- Remote query: SELECT count(*) FROM (SELECT * FROM ONLY fast_emp4000 WHERE (home_base IS NULL)) group_1
-(7 rows)
+ Remote query: SELECT count(*) FROM (SELECT * FROM ONLY fast_emp4000 WHERE (home_base IS NULL)) group_1
+(5 rows)
SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL;
count
@@ -277,17 +271,15 @@ SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL;
EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
ORDER BY (poly_center(f1))[0];
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------
Sort
- Output: id, f1, ((poly_center(f1))[0])
+ Output: polygon_tbl.id, polygon_tbl.f1, ((poly_center(polygon_tbl.f1))[0])
Sort Key: ((poly_center(polygon_tbl.f1))[0])
- -> Result
- Output: id, f1, (poly_center(f1))[0]
- -> Data Node Scan on polygon_tbl
- Output: id, f1
- Remote query: SELECT id, f1 FROM ONLY polygon_tbl WHERE (f1 ~ '((1,1),(2,2),(2,1))'::polygon)
-(8 rows)
+ -> Data Node Scan on polygon_tbl "_REMOTE_TABLE_QUERY_"
+ Output: polygon_tbl.id, polygon_tbl.f1, (poly_center(polygon_tbl.f1))[0]
+ Remote query: SELECT id, f1 FROM ONLY polygon_tbl WHERE (f1 ~ '((1,1),(2,2),(2,1))'::polygon)
+(6 rows)
SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
ORDER BY (poly_center(f1))[0];
@@ -299,17 +291,15 @@ SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
ORDER BY area(f1);
- QUERY PLAN
------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------
Sort
- Output: f1, (area(f1))
+ Output: circle_tbl.f1, (area(circle_tbl.f1))
Sort Key: (area(circle_tbl.f1))
- -> Result
- Output: f1, area(f1)
- -> Data Node Scan on circle_tbl
- Output: f1
- Remote query: SELECT f1 FROM ONLY circle_tbl WHERE (f1 && '<(1,-2),1>'::circle)
-(8 rows)
+ -> Data Node Scan on circle_tbl "_REMOTE_TABLE_QUERY_"
+ Output: circle_tbl.f1, area(circle_tbl.f1)
+ Remote query: SELECT f1 FROM ONLY circle_tbl WHERE (f1 && '<(1,-2),1>'::circle)
+(6 rows)
SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
ORDER BY area(f1);
@@ -323,16 +313,14 @@ SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*)
- Remote query: SELECT count(*) FROM (SELECT * FROM ONLY gpolygon_tbl WHERE (f1 && '((1000,1000),(0,0))'::polygon)) group_1
-(7 rows)
+ Remote query: SELECT count(*) FROM (SELECT * FROM ONLY gpolygon_tbl WHERE (f1 && '((1000,1000),(0,0))'::polygon)) group_1
+(5 rows)
SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
count
@@ -342,16 +330,14 @@ SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
EXPLAIN (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*)
- Remote query: SELECT count(*) FROM (SELECT * FROM ONLY gcircle_tbl WHERE (f1 && '<(500,500),500>'::circle)) group_1
-(7 rows)
+ Remote query: SELECT count(*) FROM (SELECT * FROM ONLY gcircle_tbl WHERE (f1 && '<(500,500),500>'::circle)) group_1
+(5 rows)
SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle;
count
@@ -364,7 +350,7 @@ SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)';
QUERY PLAN
----------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl WHERE (f1 <@ '(100,100),(0,0)'::box)
(3 rows)
@@ -379,7 +365,7 @@ SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1;
QUERY PLAN
----------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl WHERE ('(100,100),(0,0)'::box @> f1)
(3 rows)
@@ -394,7 +380,7 @@ SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl WHERE (f1 <@ '((0,0),(0,100),(100,100),(50,50),(100,0),(0,0))'::polygon)
(3 rows)
@@ -409,7 +395,7 @@ SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>';
QUERY PLAN
----------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl WHERE (f1 <@ '<(50,50),50>'::circle)
(3 rows)
@@ -424,7 +410,7 @@ SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)';
QUERY PLAN
----------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl p WHERE (f1 << '(0,0)'::point)
(3 rows)
@@ -439,7 +425,7 @@ SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)';
QUERY PLAN
----------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl p WHERE (f1 >> '(0,0)'::point)
(3 rows)
@@ -454,7 +440,7 @@ SELECT count(*) FROM point_tbl p WHERE p.f1 <^ '(0.0, 0.0)';
QUERY PLAN
----------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl p WHERE (f1 <^ '(0,0)'::point)
(3 rows)
@@ -469,7 +455,7 @@ SELECT count(*) FROM point_tbl p WHERE p.f1 >^ '(0.0, 0.0)';
QUERY PLAN
----------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl p WHERE (f1 >^ '(0,0)'::point)
(3 rows)
@@ -484,7 +470,7 @@ SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)';
QUERY PLAN
-------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: count(*)
+ Output: (count(*))
Remote query: SELECT count(*) AS count FROM point_tbl p WHERE (f1 ~= '(-5,-12)'::point)
(3 rows)
@@ -499,7 +485,7 @@ SELECT * FROM point_tbl ORDER BY f1 <-> '0,1';
QUERY PLAN
---------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: point_tbl.f1, (point_tbl.f1 <-> '(0,1)'::point)
+ Output: point_tbl.f1, ((point_tbl.f1 <-> '(0,1)'::point))
Remote query: SELECT f1 FROM point_tbl ORDER BY (f1 <-> '(0,1)'::point)
(3 rows)
@@ -535,7 +521,7 @@ SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1';
QUERY PLAN
--------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: point_tbl.f1, (point_tbl.f1 <-> '(0,1)'::point)
+ Output: point_tbl.f1, ((point_tbl.f1 <-> '(0,1)'::point))
Remote query: SELECT f1 FROM point_tbl WHERE (f1 IS NOT NULL) ORDER BY (f1 <-> '(0,1)'::point)
(3 rows)
@@ -555,7 +541,7 @@ SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0
QUERY PLAN
------------------------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: point_tbl.f1, (point_tbl.f1 <-> '(0,1)'::point)
+ Output: point_tbl.f1, ((point_tbl.f1 <-> '(0,1)'::point))
Remote query: SELECT f1 FROM point_tbl WHERE (f1 <@ '(10,10),(-10,-10)'::box) ORDER BY (f1 <-> '(0,1)'::point)
(3 rows)
@@ -576,7 +562,7 @@ SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0
QUERY PLAN
------------------------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: point_tbl.f1, (point_tbl.f1 <-> '(0,1)'::point)
+ Output: point_tbl.f1, ((point_tbl.f1 <-> '(0,1)'::point))
Remote query: SELECT f1 FROM point_tbl WHERE (f1 <@ '(10,10),(-10,-10)'::box) ORDER BY (f1 <-> '(0,1)'::point)
(3 rows)
@@ -603,17 +589,15 @@ SET enable_bitmapscan = ON;
CREATE INDEX intarrayidx ON array_index_op_test USING gin (i);
explain (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------
Sort
- Output: seqno, i, t
+ Output: array_index_op_test.seqno, array_index_op_test.i, array_index_op_test.t
Sort Key: array_index_op_test.seqno
- -> Result
- Output: seqno, i, t
- -> Data Node Scan on array_index_op_test
- Output: seqno, i, t
- Remote query: SELECT seqno, i, t FROM ONLY array_index_op_test WHERE (i @> '{32}'::integer[])
-(8 rows)
+ -> Data Node Scan on array_index_op_test "_REMOTE_TABLE_QUERY_"
+ Output: array_index_op_test.seqno, array_index_op_test.i, array_index_op_test.t
+ Remote query: SELECT seqno, i, t FROM ONLY array_index_op_test WHERE (i @> '{32}'::integer[])
+(6 rows)
SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno;
seqno | i | t
@@ -851,17 +835,15 @@ SELECT * FROM array_op_test WHERE i <@ '{NULL}' ORDER BY seqno;
CREATE INDEX textarrayidx ON array_index_op_test USING gin (t);
explain (num_nodes off, nodes off, verbose on, COSTS OFF)
SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------
Sort
- Output: seqno, i, t
+ Output: array_index_op_test.seqno, array_index_op_test.i, array_index_op_test.t
Sort Key: array_index_op_test.seqno
- -> Result
- Output: seqno, i, t
- -> Data Node Scan on array_index_op_test
- Output: seqno, i, t
- Remote query: SELECT seqno, i, t FROM ONLY array_index_op_test WHERE (t @> '{AAAAAAAA72908}'::text[])
-(8 rows)
+ -> Data Node Scan on array_index_op_test "_REMOTE_TABLE_QUERY_"
+ Output: array_index_op_test.seqno, array_index_op_test.i, array_index_op_test.t
+ Remote query: SELECT seqno, i, t FROM ONLY array_index_op_test WHERE (t @> '{AAAAAAAA72908}'::text[])
+(6 rows)
SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno;
seqno | i | t
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 4eb01332c3..bcc414f1c3 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -1733,16 +1733,16 @@ explain (verbose, costs off, nodes off) select * from matest0 order by 1-id;
-> Result
Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id)
-> Append
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest0 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest1 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest1 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest2 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest2 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest3 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest3 matest0 WHERE true
(18 rows)
@@ -1769,16 +1769,16 @@ explain (verbose, costs off, nodes off) select * from matest0 order by 1-id;
-> Result
Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id)
-> Append
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest0 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest1 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest1 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest2 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest2 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest3 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest3 matest0 WHERE true
(18 rows)
diff --git a/src/test/regress/expected/inherit_1.out b/src/test/regress/expected/inherit_1.out
index 381580bf34..42bdcffe39 100644
--- a/src/test/regress/expected/inherit_1.out
+++ b/src/test/regress/expected/inherit_1.out
@@ -1431,16 +1431,16 @@ explain (verbose, costs off, nodes off) select * from matest0 order by 1-id;
-> Result
Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id)
-> Append
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest0 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest1 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest1 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest2 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest2 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest3 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest3 matest0 WHERE true
(18 rows)
@@ -1467,16 +1467,16 @@ explain (verbose, costs off, nodes off) select * from matest0 order by 1-id;
-> Result
Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id)
-> Append
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest0 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest1 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest1 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest2 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest2 matest0 WHERE true
- -> Data Node Scan on matest0
+ -> Data Node Scan on matest3 "_REMOTE_TABLE_QUERY_"
Output: public.matest0.id, public.matest0.name
Remote query: SELECT id, name FROM ONLY matest3 matest0 WHERE true
(18 rows)
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 942a77262d..76cb3622a9 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -2594,36 +2594,30 @@ INSERT INTO b VALUES (0, 0), (1, NULL);
INSERT INTO c VALUES (0), (1);
-- all three cases should be optimizable into a simple seqscan
explain (verbose true, costs false, nodes false) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id;
- QUERY PLAN
---------------------------------------------------------------
- Result
+ QUERY PLAN
+--------------------------------------------------------
+ Data Node Scan on a "_REMOTE_TABLE_QUERY_"
Output: a.id, a.b_id
- -> Data Node Scan on a
- Output: a.id, a.b_id
- Remote query: SELECT id, b_id FROM ONLY a WHERE true
-(5 rows)
+ Remote query: SELECT id, b_id FROM ONLY a WHERE true
+(3 rows)
explain (verbose true, costs false, nodes false) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
- QUERY PLAN
---------------------------------------------------------------
- Result
+ QUERY PLAN
+--------------------------------------------------------
+ Data Node Scan on b "_REMOTE_TABLE_QUERY_"
Output: b.id, b.c_id
- -> Data Node Scan on b
- Output: b.id, b.c_id
- Remote query: SELECT id, c_id FROM ONLY b WHERE true
-(5 rows)
+ Remote query: SELECT id, c_id FROM ONLY b WHERE true
+(3 rows)
explain (verbose true, costs false, nodes false)
SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id)
ON (a.b_id = b.id);
- QUERY PLAN
---------------------------------------------------------------
- Result
+ QUERY PLAN
+--------------------------------------------------------
+ Data Node Scan on a "_REMOTE_TABLE_QUERY_"
Output: a.id, a.b_id
- -> Data Node Scan on a
- Output: a.id, a.b_id
- Remote query: SELECT id, b_id FROM ONLY a WHERE true
-(5 rows)
+ Remote query: SELECT id, b_id FROM ONLY a WHERE true
+(3 rows)
-- check optimization of outer join within another special join
explain (verbose true, costs false, nodes false)
@@ -2635,10 +2629,10 @@ select id from a where id in (
Nested Loop Semi Join
Output: a.id
Join Filter: (a.id = b.id)
- -> Data Node Scan on a
+ -> Data Node Scan on a "_REMOTE_TABLE_QUERY_"
Output: a.id
Remote query: SELECT id FROM ONLY a WHERE true
- -> Data Node Scan on b
+ -> Data Node Scan on b "_REMOTE_TABLE_QUERY_"
Output: b.id
Remote query: SELECT id FROM ONLY b WHERE true
(9 rows)
@@ -2661,17 +2655,15 @@ select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
explain (verbose true, costs false, nodes false)
select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
- QUERY PLAN
-------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Sort
Output: p.k, p.pd
Sort Key: p.k, p.pd
- -> Result
+ -> Data Node Scan on parent "_REMOTE_TABLE_QUERY_"
Output: p.k, p.pd
- -> Data Node Scan on p
- Output: p.k, p.pd
- Remote query: SELECT k, pd FROM ONLY parent p WHERE true
-(8 rows)
+ Remote query: SELECT k, pd FROM ONLY parent p WHERE true
+(6 rows)
-- this case is not
select p.*, linked from parent p
@@ -2696,14 +2688,12 @@ explain (verbose true, costs false, nodes false)
-> Nested Loop Left Join
Output: p.k, p.pd, (true)
Join Filter: (p.k = c.k)
- -> Data Node Scan on p
+ -> Data Node Scan on parent "_REMOTE_TABLE_QUERY_"
Output: p.k, p.pd
Remote query: SELECT k, pd FROM ONLY parent p WHERE true
- -> Result
+ -> Data Node Scan on child "_REMOTE_TABLE_QUERY_"
Output: c.k, true
- -> Data Node Scan on c
- Output: c.k
- Remote query: SELECT k FROM ONLY child c WHERE true
+ Remote query: SELECT k FROM ONLY child c WHERE true
(14 rows)
-- check for a 9.0rc1 bug: join removal breaks pseudoconstant qual handling
@@ -2723,7 +2713,7 @@ select p.* from
Result
Output: p.k, p.pd
One-Time Filter: false
- -> Data Node Scan on p
+ -> Data Node Scan on parent "_REMOTE_TABLE_QUERY_"
Output: p.k, p.pd
Remote query: SELECT k, pd FROM ONLY parent p WHERE (k = 1)
(6 rows)
diff --git a/src/test/regress/expected/join_1.out b/src/test/regress/expected/join_1.out
index 18438491a3..28b41b1fc6 100644
--- a/src/test/regress/expected/join_1.out
+++ b/src/test/regress/expected/join_1.out
@@ -2590,36 +2590,30 @@ INSERT INTO b VALUES (0, 0), (1, NULL);
INSERT INTO c VALUES (0), (1);
-- all three cases should be optimizable into a simple seqscan
explain (verbose true, costs false, nodes false) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id;
- QUERY PLAN
---------------------------------------------------------------
- Result
+ QUERY PLAN
+--------------------------------------------------------
+ Data Node Scan on a "_REMOTE_TABLE_QUERY_"
Output: a.id, a.b_id
- -> Data Node Scan on a
- Output: a.id, a.b_id
- Remote query: SELECT id, b_id FROM ONLY a WHERE true
-(5 rows)
+ Remote query: SELECT id, b_id FROM ONLY a WHERE true
+(3 rows)
explain (verbose true, costs false, nodes false) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
- QUERY PLAN
---------------------------------------------------------------
- Result
+ QUERY PLAN
+--------------------------------------------------------
+ Data Node Scan on b "_REMOTE_TABLE_QUERY_"
Output: b.id, b.c_id
- -> Data Node Scan on b
- Output: b.id, b.c_id
- Remote query: SELECT id, c_id FROM ONLY b WHERE true
-(5 rows)
+ Remote query: SELECT id, c_id FROM ONLY b WHERE true
+(3 rows)
explain (verbose true, costs false, nodes false)
SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id)
ON (a.b_id = b.id);
- QUERY PLAN
---------------------------------------------------------------
- Result
+ QUERY PLAN
+--------------------------------------------------------
+ Data Node Scan on a "_REMOTE_TABLE_QUERY_"
Output: a.id, a.b_id
- -> Data Node Scan on a
- Output: a.id, a.b_id
- Remote query: SELECT id, b_id FROM ONLY a WHERE true
-(5 rows)
+ Remote query: SELECT id, b_id FROM ONLY a WHERE true
+(3 rows)
-- check optimization of outer join within another special join
explain (verbose true, costs false, nodes false)
@@ -2631,10 +2625,10 @@ select id from a where id in (
Nested Loop Semi Join
Output: a.id
Join Filter: (a.id = b.id)
- -> Data Node Scan on a
+ -> Data Node Scan on a "_REMOTE_TABLE_QUERY_"
Output: a.id
Remote query: SELECT id FROM ONLY a WHERE true
- -> Data Node Scan on b
+ -> Data Node Scan on b "_REMOTE_TABLE_QUERY_"
Output: b.id
Remote query: SELECT id FROM ONLY b WHERE true
(9 rows)
@@ -2657,17 +2651,15 @@ select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
explain (verbose true, costs false, nodes false)
select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
- QUERY PLAN
-------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Sort
Output: p.k, p.pd
Sort Key: p.k, p.pd
- -> Result
+ -> Data Node Scan on parent "_REMOTE_TABLE_QUERY_"
Output: p.k, p.pd
- -> Data Node Scan on p
- Output: p.k, p.pd
- Remote query: SELECT k, pd FROM ONLY parent p WHERE true
-(8 rows)
+ Remote query: SELECT k, pd FROM ONLY parent p WHERE true
+(6 rows)
-- this case is not
select p.*, linked from parent p
@@ -2684,23 +2676,21 @@ explain (verbose true, costs false, nodes false)
select p.*, linked from parent p
left join (select c.*, true as linked from child c) as ss
on (p.k = ss.k) order by p.k;
- QUERY PLAN
--------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------
Sort
Output: p.k, p.pd, (true)
Sort Key: p.k
-> Nested Loop Left Join
Output: p.k, p.pd, (true)
Join Filter: (p.k = c.k)
- -> Data Node Scan on p
+ -> Data Node Scan on parent "_REMOTE_TABLE_QUERY_"
Output: p.k, p.pd
Remote query: SELECT k, pd FROM ONLY parent p WHERE true
- -> Result
+ -> Data Node Scan on child "_REMOTE_TABLE_QUERY_"
Output: c.k, true
- -> Data Node Scan on c
- Output: c.k
- Remote query: SELECT k FROM ONLY child c WHERE true
-(14 rows)
+ Remote query: SELECT k FROM ONLY child c WHERE true
+(12 rows)
-- check for a 9.0rc1 bug: join removal breaks pseudoconstant qual handling
select p.* from
@@ -2719,7 +2709,7 @@ select p.* from
Result
Output: p.k, p.pd
One-Time Filter: false
- -> Data Node Scan on p
+ -> Data Node Scan on parent "_REMOTE_TABLE_QUERY_"
Output: p.k, p.pd
Remote query: SELECT k, pd FROM ONLY parent p WHERE (k = 1)
(6 rows)
diff --git a/src/test/regress/expected/xc_FQS.out b/src/test/regress/expected/xc_FQS.out
index 30cc78434a..169ae5ab31 100644
--- a/src/test/regress/expected/xc_FQS.out
+++ b/src/test/regress/expected/xc_FQS.out
@@ -52,7 +52,7 @@ explain (costs off, verbose on, nodes off, num_nodes on) insert into tab1_rr val
QUERY PLAN
-------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: 9, 2
+ Output: (9), (2)
Remote query: INSERT INTO tab1_rr (val, val2) VALUES (9, 2)
(3 rows)
@@ -68,7 +68,7 @@ explain (costs off, verbose on, nodes off) select val, val2 + 2, case val when v
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: tab1_rr.val, (tab1_rr.val2 + 2), CASE tab1_rr.val WHEN tab1_rr.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ Output: tab1_rr.val, ((tab1_rr.val2 + 2)), (CASE tab1_rr.val WHEN tab1_rr.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END)
Remote query: SELECT val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END AS "case" FROM tab1_rr WHERE (val2 = 4)
(3 rows)
@@ -80,16 +80,14 @@ select sum(val), avg(val), count(*) from tab1_rr;
(1 row)
explain (costs off, verbose on, nodes off) select sum(val), avg(val), count(*) from tab1_rr;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.sum((sum(tab1_rr.val))), pg_catalog.avg((avg(tab1_rr.val))), pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(tab1_rr.val)), (avg(tab1_rr.val)), (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(tab1_rr.val), avg(tab1_rr.val), count(*)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), count(*) FROM (SELECT val FROM ONLY tab1_rr WHERE true) group_1
-(7 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), count(*) FROM (SELECT val FROM ONLY tab1_rr WHERE true) group_1
+(5 rows)
-- should not get FQSed because of window functions
select first_value(val) over (partition by val2 order by val) from tab1_rr;
@@ -103,19 +101,17 @@ select first_value(val) over (partition by val2 order by val) from tab1_rr;
(5 rows)
explain (costs off, verbose on, nodes off) select first_value(val) over (partition by val2 order by val) from tab1_rr;
- QUERY PLAN
----------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------
WindowAgg
- Output: first_value(val) OVER (?), val, val2
+ Output: first_value(tab1_rr.val) OVER (?), tab1_rr.val, tab1_rr.val2
-> Sort
- Output: val, val2
+ Output: tab1_rr.val, tab1_rr.val2
Sort Key: tab1_rr.val2, tab1_rr.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE true
-(10 rows)
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE true
+(8 rows)
-- should not get FQSed because of LIMIT clause
select * from tab1_rr where val2 = 3 limit 1;
@@ -125,16 +121,14 @@ select * from tab1_rr where val2 = 3 limit 1;
(1 row)
explain (costs off, verbose on, nodes off) select * from tab1_rr where val2 = 3 limit 1;
- QUERY PLAN
----------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------
Limit
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 3)
-(7 rows)
+ Output: tab1_rr.val, tab1_rr.val2
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 3)
+(5 rows)
-- should not FQSed because of OFFSET clause
select * from tab1_rr where val2 = 4 offset 1;
@@ -143,16 +137,14 @@ select * from tab1_rr where val2 = 4 offset 1;
(0 rows)
explain (costs off, verbose on, nodes off) select * from tab1_rr where val2 = 4 offset 1;
- QUERY PLAN
----------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------
Limit
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 4)
-(7 rows)
+ Output: tab1_rr.val, tab1_rr.val2
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 4)
+(5 rows)
-- should not get FQSed because of SORT clause
select * from tab1_rr order by val;
@@ -166,17 +158,15 @@ select * from tab1_rr order by val;
(5 rows)
explain (costs off, verbose on, nodes off) select * from tab1_rr order by val;
- QUERY PLAN
----------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_rr.val, tab1_rr.val2
Sort Key: tab1_rr.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE true
-(8 rows)
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE true
+(6 rows)
-- should not get FQSed because of DISTINCT clause
select distinct val, val2 from tab1_rr where val2 = 8;
@@ -186,16 +176,14 @@ select distinct val, val2 from tab1_rr where val2 = 8;
(1 row)
explain (costs off, verbose on, nodes off) select distinct val, val2 from tab1_rr where val2 = 8;
- QUERY PLAN
----------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------
HashAggregate
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 8)
-(7 rows)
+ Output: tab1_rr.val, tab1_rr.val2
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 8)
+(5 rows)
-- should not get FQSed because of GROUP clause
select val, val2 from tab1_rr where val2 = 8 group by val, val2;
@@ -205,16 +193,14 @@ select val, val2 from tab1_rr where val2 = 8 group by val, val2;
(1 row)
explain (costs off, verbose on, nodes off) select val, val2 from tab1_rr where val2 = 8 group by val, val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: tab1_rr.val, tab1_rr.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: tab1_rr.val, tab1_rr.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: tab1_rr.val, tab1_rr.val2
- Remote query: SELECT group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 8)) group_1 GROUP BY 1, 2
-(7 rows)
+ Remote query: SELECT group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 8)) group_1 GROUP BY 1, 2
+(5 rows)
-- should not get FQSed because of HAVING clause
select sum(val) from tab1_rr where val2 = 2 group by val2 having sum(val) > 1;
@@ -224,17 +210,15 @@ select sum(val) from tab1_rr where val2 = 2 group by val2 having sum(val) > 1;
(1 row)
explain (costs off, verbose on, nodes off) select sum(val) from tab1_rr where val2 = 2 group by val2 having sum(val) > 1;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(tab1_rr.val))), tab1_rr.val2
Filter: (pg_catalog.sum((sum(tab1_rr.val))) > 1)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(tab1_rr.val)), tab1_rr.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(tab1_rr.val), tab1_rr.val2
- Remote query: SELECT sum(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 2)) group_1 GROUP BY 2
-(8 rows)
+ Remote query: SELECT sum(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_rr WHERE (val2 = 2)) group_1 GROUP BY 2
+(6 rows)
-- tests for node reduction by application of quals, for round robin node
-- reduction is not applicable. Having query not FQSed because of existence of ORDER BY,
@@ -261,17 +245,15 @@ select * from tab1_rr where val = 7 or val = 2 order by val;
(2 rows)
explain (costs off, verbose on, nodes off) select * from tab1_rr where val = 7 or val = 2 order by val;
- QUERY PLAN
------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_rr.val, tab1_rr.val2
Sort Key: tab1_rr.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE ((val = 7) OR (val = 2))
-(8 rows)
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE ((val = 7) OR (val = 2))
+(6 rows)
select * from tab1_rr where val = 7 and val2 = 8;
val | val2
@@ -280,14 +262,12 @@ select * from tab1_rr where val = 7 and val2 = 8;
(1 row)
explain (costs off, verbose on, nodes off) select * from tab1_rr where val = 7 and val2 = 8 order by val;
- QUERY PLAN
--------------------------------------------------------------------------------------------
- Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE ((val = 7) AND (val2 = 8))
-(5 rows)
+ QUERY PLAN
+-------------------------------------------------------------------------------------
+ Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE ((val = 7) AND (val2 = 8))
+(3 rows)
select * from tab1_rr where val = 3 + 4 and val2 = 8 order by val;
val | val2
@@ -296,14 +276,12 @@ select * from tab1_rr where val = 3 + 4 and val2 = 8 order by val;
(1 row)
explain (costs off, verbose on, nodes off) select * from tab1_rr where val = 3 + 4 order by val;
- QUERY PLAN
---------------------------------------------------------------------------
- Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val = 7)
-(5 rows)
+ QUERY PLAN
+--------------------------------------------------------------------
+ Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val = 7)
+(3 rows)
select * from tab1_rr where val = char_length('len')+4 order by val;
val | val2
@@ -312,14 +290,12 @@ select * from tab1_rr where val = char_length('len')+4 order by val;
(1 row)
explain (costs off, verbose on, nodes off) select * from tab1_rr where val = char_length('len')+4 order by val;
- QUERY PLAN
---------------------------------------------------------------------------
- Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val = 7)
-(5 rows)
+ QUERY PLAN
+--------------------------------------------------------------------
+ Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val = 7)
+(3 rows)
-- insert some more values
insert into tab1_rr values (7, 2);
@@ -330,16 +306,14 @@ select avg(val) from tab1_rr where val = 7;
(1 row)
explain (costs off, verbose on, nodes off) select avg(val) from tab1_rr where val = 7;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.avg((avg(tab1_rr.val)))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(tab1_rr.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(tab1_rr.val)
- Remote query: SELECT avg(group_1.val) FROM (SELECT val FROM ONLY tab1_rr WHERE (val = 7)) group_1
-(7 rows)
+ Remote query: SELECT avg(group_1.val) FROM (SELECT val FROM ONLY tab1_rr WHERE (val = 7)) group_1
+(5 rows)
select val, val2 from tab1_rr where val = 7 order by val2;
val | val2
@@ -349,17 +323,15 @@ select val, val2 from tab1_rr where val = 7 order by val2;
(2 rows)
explain (costs off, verbose on, nodes off) select val, val2 from tab1_rr where val = 7 order by val2;
- QUERY PLAN
---------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_rr.val, tab1_rr.val2
Sort Key: tab1_rr.val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_rr
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val = 7)
-(8 rows)
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val, tab1_rr.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_rr WHERE (val = 7)
+(6 rows)
select distinct val2 from tab1_rr where val = 7;
val2
@@ -369,16 +341,14 @@ select distinct val2 from tab1_rr where val = 7;
(2 rows)
explain (costs off, verbose on, nodes off) select distinct val2 from tab1_rr where val = 7;
- QUERY PLAN
----------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------
HashAggregate
- Output: val2
- -> Result
- Output: val2
- -> Data Node Scan on tab1_rr
- Output: val2
- Remote query: SELECT val2 FROM ONLY tab1_rr WHERE (val = 7)
-(7 rows)
+ Output: tab1_rr.val2
+ -> Data Node Scan on tab1_rr "_REMOTE_TABLE_QUERY_"
+ Output: tab1_rr.val2
+ Remote query: SELECT val2 FROM ONLY tab1_rr WHERE (val = 7)
+(5 rows)
-- DMLs
update tab1_rr set val2 = 1000 where val = 7;
@@ -386,7 +356,7 @@ explain (costs off, verbose on, nodes off) update tab1_rr set val2 = 1000 where
QUERY PLAN
----------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 1000, tab1_rr.val, tab1_rr.ctid, tab1_rr.xc_node_id
+ Output: (1000), (1000), tab1_rr.ctid, tab1_rr.xc_node_id
Remote query: UPDATE tab1_rr SET val2 = 1000 WHERE (val = 7)
(3 rows)
@@ -427,7 +397,7 @@ explain (costs off, verbose on, nodes off) insert into tab1_hash values (9, 2);
QUERY PLAN
-----------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 9, 2
+ Output: (9), (2)
Node expr: 9
Remote query: INSERT INTO tab1_hash (val, val2) VALUES (9, 2)
(4 rows)
@@ -444,7 +414,7 @@ explain (costs off, verbose on, nodes off) select val, val2 + 2, case val when v
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: tab1_hash.val, (tab1_hash.val2 + 2), CASE tab1_hash.val WHEN tab1_hash.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ Output: tab1_hash.val, ((tab1_hash.val2 + 2)), (CASE tab1_hash.val WHEN tab1_hash.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END)
Remote query: SELECT val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END AS "case" FROM tab1_hash WHERE (val2 = 2)
(3 rows)
@@ -456,16 +426,14 @@ select sum(val), avg(val), count(*) from tab1_hash;
(1 row)
explain (costs off, verbose on, nodes off) select sum(val), avg(val), count(*) from tab1_hash;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.sum((sum(tab1_hash.val))), pg_catalog.avg((avg(tab1_hash.val))), pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(tab1_hash.val)), (avg(tab1_hash.val)), (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(tab1_hash.val), avg(tab1_hash.val), count(*)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), count(*) FROM (SELECT val FROM ONLY tab1_hash WHERE true) group_1
-(7 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), count(*) FROM (SELECT val FROM ONLY tab1_hash WHERE true) group_1
+(5 rows)
-- should not get FQSed because of window functions
select first_value(val) over (partition by val2 order by val) from tab1_hash;
@@ -479,19 +447,17 @@ select first_value(val) over (partition by val2 order by val) from tab1_hash;
(5 rows)
explain (costs off, verbose on, nodes off) select first_value(val) over (partition by val2 order by val) from tab1_hash;
- QUERY PLAN
------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------
WindowAgg
- Output: first_value(val) OVER (?), val, val2
+ Output: first_value(tab1_hash.val) OVER (?), tab1_hash.val, tab1_hash.val2
-> Sort
- Output: val, val2
+ Output: tab1_hash.val, tab1_hash.val2
Sort Key: tab1_hash.val2, tab1_hash.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_hash
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE true
-(10 rows)
+ -> Data Node Scan on tab1_hash "_REMOTE_TABLE_QUERY_"
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE true
+(8 rows)
-- should not get FQSed because of LIMIT clause
select * from tab1_hash where val2 = 3 limit 1;
@@ -501,16 +467,14 @@ select * from tab1_hash where val2 = 3 limit 1;
(1 row)
explain (costs off, verbose on, nodes off) select * from tab1_hash where val2 = 3 limit 1;
- QUERY PLAN
------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------
Limit
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_hash
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 3)
-(7 rows)
+ Output: tab1_hash.val, tab1_hash.val2
+ -> Data Node Scan on tab1_hash "_REMOTE_TABLE_QUERY_"
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 3)
+(5 rows)
-- should not FQSed because of OFFSET clause
select * from tab1_hash where val2 = 4 offset 1;
@@ -519,16 +483,14 @@ select * from tab1_hash where val2 = 4 offset 1;
(0 rows)
explain (costs off, verbose on, nodes off) select * from tab1_hash where val2 = 4 offset 1;
- QUERY PLAN
------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------
Limit
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_hash
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 4)
-(7 rows)
+ Output: tab1_hash.val, tab1_hash.val2
+ -> Data Node Scan on tab1_hash "_REMOTE_TABLE_QUERY_"
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 4)
+(5 rows)
-- should not get FQSed because of SORT clause
select * from tab1_hash order by val;
@@ -542,17 +504,15 @@ select * from tab1_hash order by val;
(5 rows)
explain (costs off, verbose on, nodes off) select * from tab1_hash order by val;
- QUERY PLAN
------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_hash.val, tab1_hash.val2
Sort Key: tab1_hash.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_hash
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE true
-(8 rows)
+ -> Data Node Scan on tab1_hash "_REMOTE_TABLE_QUERY_"
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE true
+(6 rows)
-- should not get FQSed because of DISTINCT clause
select distinct val, val2 from tab1_hash where val2 = 8;
@@ -562,16 +522,14 @@ select distinct val, val2 from tab1_hash where val2 = 8;
(1 row)
explain (costs off, verbose on, nodes off) select distinct val, val2 from tab1_hash where val2 = 8;
- QUERY PLAN
------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------
HashAggregate
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_hash
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 8)
-(7 rows)
+ Output: tab1_hash.val, tab1_hash.val2
+ -> Data Node Scan on tab1_hash "_REMOTE_TABLE_QUERY_"
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 8)
+(5 rows)
-- should not get FQSed because of GROUP clause
select val, val2 from tab1_hash where val2 = 8 group by val, val2;
@@ -581,16 +539,14 @@ select val, val2 from tab1_hash where val2 = 8 group by val, val2;
(1 row)
explain (costs off, verbose on, nodes off) select val, val2 from tab1_hash where val2 = 8 group by val, val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: tab1_hash.val, tab1_hash.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: tab1_hash.val, tab1_hash.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: tab1_hash.val, tab1_hash.val2
- Remote query: SELECT group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 8)) group_1 GROUP BY 1, 2
-(7 rows)
+ Remote query: SELECT group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 8)) group_1 GROUP BY 1, 2
+(5 rows)
-- should not get FQSed because of HAVING clause
select sum(val) from tab1_hash where val2 = 2 group by val2 having sum(val) > 1;
@@ -600,17 +556,15 @@ select sum(val) from tab1_hash where val2 = 2 group by val2 having sum(val) > 1;
(1 row)
explain (costs off, verbose on, nodes off) select sum(val) from tab1_hash where val2 = 2 group by val2 having sum(val) > 1;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(tab1_hash.val))), tab1_hash.val2
Filter: (pg_catalog.sum((sum(tab1_hash.val))) > 1)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(tab1_hash.val)), tab1_hash.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(tab1_hash.val), tab1_hash.val2
- Remote query: SELECT sum(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 2)) group_1 GROUP BY 2
-(8 rows)
+ Remote query: SELECT sum(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_hash WHERE (val2 = 2)) group_1 GROUP BY 2
+(6 rows)
-- tests for node reduction by application of quals. Having query FQSed because of
-- existence of ORDER BY, implies that nodes got reduced.
@@ -636,17 +590,15 @@ select * from tab1_hash where val = 7 or val = 2 order by val;
(2 rows)
explain (costs off, verbose on, nodes off) select * from tab1_hash where val = 7 or val = 2 order by val;
- QUERY PLAN
--------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_hash.val, tab1_hash.val2
Sort Key: tab1_hash.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_hash
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE ((val = 7) OR (val = 2))
-(8 rows)
+ -> Data Node Scan on tab1_hash "_REMOTE_TABLE_QUERY_"
+ Output: tab1_hash.val, tab1_hash.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_hash WHERE ((val = 7) OR (val = 2))
+(6 rows)
select * from tab1_hash where val = 7 and val2 = 8;
val | val2
@@ -702,7 +654,7 @@ explain (costs off, verbose on, nodes off, num_nodes on) select avg(val) from ta
QUERY PLAN
--------------------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: avg(tab1_hash.val)
+ Output: (avg(tab1_hash.val))
Remote query: SELECT pg_catalog.int8_avg(avg(val)) AS avg FROM tab1_hash WHERE (val = 7)
(3 rows)
@@ -739,10 +691,10 @@ explain (costs off, verbose on, nodes off, num_nodes on) select distinct val2 fr
-- DMLs
update tab1_hash set val2 = 1000 where val = 7;
explain (costs off, verbose on, nodes off) update tab1_hash set val2 = 1000 where val = 7;
- QUERY PLAN
----------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 1000, tab1_hash.val, tab1_hash.ctid, tab1_hash.xc_node_id
+ Output: (1000), (1000), tab1_hash.ctid, tab1_hash.xc_node_id
Remote query: UPDATE tab1_hash SET val2 = 1000 WHERE (val = 7)
(3 rows)
@@ -783,7 +735,7 @@ explain (costs off, verbose on, nodes off) insert into tab1_modulo values (9, 2)
QUERY PLAN
-------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 9, 2
+ Output: (9), (2)
Node expr: 9
Remote query: INSERT INTO tab1_modulo (val, val2) VALUES (9, 2)
(4 rows)
@@ -800,7 +752,7 @@ explain (costs off, verbose on, nodes off) select val, val2 + 2, case val when v
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: tab1_modulo.val, (tab1_modulo.val2 + 2), CASE tab1_modulo.val WHEN tab1_modulo.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END
+ Output: tab1_modulo.val, ((tab1_modulo.val2 + 2)), (CASE tab1_modulo.val WHEN tab1_modulo.val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END)
Remote query: SELECT val, (val2 + 2), CASE val WHEN val2 THEN 'val and val2 are same'::text ELSE 'val and val2 are not same'::text END AS "case" FROM tab1_modulo WHERE (val2 = 4)
(3 rows)
@@ -812,16 +764,14 @@ select sum(val), avg(val), count(*) from tab1_modulo;
(1 row)
explain (costs off, verbose on, nodes off) select sum(val), avg(val), count(*) from tab1_modulo;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
Aggregate
Output: pg_catalog.sum((sum(tab1_modulo.val))), pg_catalog.avg((avg(tab1_modulo.val))), pg_catalog.count(*)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(tab1_modulo.val)), (avg(tab1_modulo.val)), (count(*))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(tab1_modulo.val), avg(tab1_modulo.val), count(*)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), count(*) FROM (SELECT val FROM ONLY tab1_modulo WHERE true) group_1
-(7 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), count(*) FROM (SELECT val FROM ONLY tab1_modulo WHERE true) group_1
+(5 rows)
-- should not get FQSed because of window functions
select first_value(val) over (partition by val2 order by val) from tab1_modulo;
@@ -835,19 +785,17 @@ select first_value(val) over (partition by val2 order by val) from tab1_modulo;
(5 rows)
explain (costs off, verbose on, nodes off) select first_value(val) over (partition by val2 order by val) from tab1_modulo;
- QUERY PLAN
--------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------
WindowAgg
- Output: first_value(val) OVER (?), val, val2
+ Output: first_value(tab1_modulo.val) OVER (?), tab1_modulo.val, tab1_modulo.val2
-> Sort
- Output: val, val2
+ Output: tab1_modulo.val, tab1_modulo.val2
Sort Key: tab1_modulo.val2, tab1_modulo.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_modulo
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE true
-(10 rows)
+ -> Data Node Scan on tab1_modulo "_REMOTE_TABLE_QUERY_"
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE true
+(8 rows)
-- should not get FQSed because of LIMIT clause
select * from tab1_modulo where val2 = 3 limit 1;
@@ -857,16 +805,14 @@ select * from tab1_modulo where val2 = 3 limit 1;
(1 row)
explain (costs off, verbose on, nodes off) select * from tab1_modulo where val2 = 3 limit 1;
- QUERY PLAN
--------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------
Limit
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_modulo
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 3)
-(7 rows)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ -> Data Node Scan on tab1_modulo "_REMOTE_TABLE_QUERY_"
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 3)
+(5 rows)
-- should not FQSed because of OFFSET clause
select * from tab1_modulo where val2 = 4 offset 1;
@@ -875,16 +821,14 @@ select * from tab1_modulo where val2 = 4 offset 1;
(0 rows)
explain (costs off, verbose on, nodes off) select * from tab1_modulo where val2 = 4 offset 1;
- QUERY PLAN
--------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------
Limit
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_modulo
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 4)
-(7 rows)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ -> Data Node Scan on tab1_modulo "_REMOTE_TABLE_QUERY_"
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 4)
+(5 rows)
-- should not get FQSed because of SORT clause
select * from tab1_modulo order by val;
@@ -898,17 +842,15 @@ select * from tab1_modulo order by val;
(5 rows)
explain (costs off, verbose on, nodes off) select * from tab1_modulo order by val;
- QUERY PLAN
--------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_modulo.val, tab1_modulo.val2
Sort Key: tab1_modulo.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_modulo
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE true
-(8 rows)
+ -> Data Node Scan on tab1_modulo "_REMOTE_TABLE_QUERY_"
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE true
+(6 rows)
-- should not get FQSed because of DISTINCT clause
select distinct val, val2 from tab1_modulo where val2 = 8;
@@ -918,16 +860,14 @@ select distinct val, val2 from tab1_modulo where val2 = 8;
(1 row)
explain (costs off, verbose on, nodes off) select distinct val, val2 from tab1_modulo where val2 = 8;
- QUERY PLAN
--------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------
HashAggregate
- Output: val, val2
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_modulo
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 8)
-(7 rows)
+ Output: tab1_modulo.val, tab1_modulo.val2
+ -> Data Node Scan on tab1_modulo "_REMOTE_TABLE_QUERY_"
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 8)
+(5 rows)
-- should not get FQSed because of GROUP clause
select val, val2 from tab1_modulo where val2 = 8 group by val, val2;
@@ -937,16 +877,14 @@ select val, val2 from tab1_modulo where val2 = 8 group by val, val2;
(1 row)
explain (costs off, verbose on, nodes off) select val, val2 from tab1_modulo where val2 = 8 group by val, val2;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: tab1_modulo.val, tab1_modulo.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: tab1_modulo.val, tab1_modulo.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: tab1_modulo.val, tab1_modulo.val2
- Remote query: SELECT group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 8)) group_1 GROUP BY 1, 2
-(7 rows)
+ Remote query: SELECT group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 8)) group_1 GROUP BY 1, 2
+(5 rows)
-- should not get FQSed because of HAVING clause
select sum(val) from tab1_modulo where val2 = 2 group by val2 having sum(val) > 1;
@@ -956,17 +894,15 @@ select sum(val) from tab1_modulo where val2 = 2 group by val2 having sum(val) >
(1 row)
explain (costs off, verbose on, nodes off) select sum(val) from tab1_modulo where val2 = 2 group by val2 having sum(val) > 1;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(tab1_modulo.val))), tab1_modulo.val2
Filter: (pg_catalog.sum((sum(tab1_modulo.val))) > 1)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(tab1_modulo.val)), tab1_modulo.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(tab1_modulo.val), tab1_modulo.val2
- Remote query: SELECT sum(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 2)) group_1 GROUP BY 2
-(8 rows)
+ Remote query: SELECT sum(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY tab1_modulo WHERE (val2 = 2)) group_1 GROUP BY 2
+(6 rows)
-- tests for node reduction by application of quals. Having query FQSed because of
-- existence of ORDER BY, implies that nodes got reduced.
@@ -992,17 +928,15 @@ select * from tab1_modulo where val = 7 or val = 2 order by val;
(2 rows)
explain (costs off, verbose on, nodes off) select * from tab1_modulo where val = 7 or val = 2 order by val;
- QUERY PLAN
----------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------
Sort
- Output: val, val2
+ Output: tab1_modulo.val, tab1_modulo.val2
Sort Key: tab1_modulo.val
- -> Result
- Output: val, val2
- -> Data Node Scan on tab1_modulo
- Output: val, val2
- Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE ((val = 7) OR (val = 2))
-(8 rows)
+ -> Data Node Scan on tab1_modulo "_REMOTE_TABLE_QUERY_"
+ Output: tab1_modulo.val, tab1_modulo.val2
+ Remote query: SELECT val, val2 FROM ONLY tab1_modulo WHERE ((val = 7) OR (val = 2))
+(6 rows)
select * from tab1_modulo where val = 7 and val2 = 8;
val | val2
@@ -1058,7 +992,7 @@ explain (costs off, verbose on, nodes off, num_nodes on) select avg(val) from ta
QUERY PLAN
----------------------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: avg(tab1_modulo.val)
+ Output: (avg(tab1_modulo.val))
Remote query: SELECT pg_catalog.int8_avg(avg(val)) AS avg FROM tab1_modulo WHERE (val = 7)
(3 rows)
@@ -1095,10 +1029,10 @@ explain (costs off, verbose on, nodes off, num_nodes on) select distinct val2 fr
-- DMLs
update tab1_modulo set val2 = 1000 where val = 7;
explain (costs off, verbose on, nodes off) update tab1_modulo set val2 = 1000 where val = 7;
- QUERY PLAN
----------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 1000, tab1_modulo.val, tab1_modulo.ctid, tab1_modulo.xc_node_id
+ Output: (1000), (1000), tab1_modulo.ctid, tab1_modulo.xc_node_id
Remote query: UPDATE tab1_modulo SET val2 = 1000 WHERE (val = 7)
(3 rows)
@@ -1140,7 +1074,7 @@ explain (costs off, verbose on, nodes off) insert into tab1_replicated values (9
QUERY PLAN
-----------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 9, 2
+ Output: (9), (2)
Remote query: INSERT INTO tab1_replicated (val, val2) VALUES (9, 2)
(3 rows)
@@ -1173,7 +1107,7 @@ explain (costs off, num_nodes on, verbose on, nodes off) select sum(val), avg(va
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: sum(tab1_replicated.val), avg(tab1_replicated.val), count(*)
+ Output: (sum(tab1_replicated.val)), (avg(tab1_replicated.val)), (count(*))
Remote query: SELECT sum(val) AS sum, pg_catalog.int8_avg(avg(val)) AS avg, count(*) AS count FROM tab1_replicated
(3 rows)
@@ -1191,7 +1125,7 @@ explain (costs off, num_nodes on, verbose on, nodes off) select first_value(val)
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: first_value(tab1_replicated.val) OVER (?), tab1_replicated.val, tab1_replicated.val2
+ Output: (first_value(tab1_replicated.val) OVER (?)), tab1_replicated.val, tab1_replicated.val2
Remote query: SELECT first_value(val) OVER (PARTITION BY val2 ORDER BY val) AS first_value FROM tab1_replicated
(3 rows)
@@ -1290,7 +1224,7 @@ explain (costs off, num_nodes on, verbose on, nodes off) select sum(val) from ta
QUERY PLAN
-------------------------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: sum(tab1_replicated.val), tab1_replicated.val2
+ Output: (sum(tab1_replicated.val)), tab1_replicated.val2
Remote query: SELECT sum(val) AS sum FROM tab1_replicated GROUP BY val2 HAVING (sum(val) > 1)
(3 rows)
@@ -1300,7 +1234,7 @@ explain (costs off, verbose on, nodes off) update tab1_replicated set val2 = 100
QUERY PLAN
------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
- Output: 1000, tab1_replicated.val, tab1_replicated.ctid
+ Output: (1000), (1000), tab1_replicated.ctid
Remote query: UPDATE tab1_replicated SET val2 = 1000 WHERE (val = 7)
(3 rows)
diff --git a/src/test/regress/expected/xc_FQS_join.out b/src/test/regress/expected/xc_FQS_join.out
index 2b702aa2d0..a0848b8b4a 100644
--- a/src/test/regress/expected/xc_FQS_join.out
+++ b/src/test/regress/expected/xc_FQS_join.out
@@ -200,7 +200,7 @@ explain (costs off, num_nodes on, nodes off, verbose on) select avg(tab1_rep.val
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Data Node Scan (primary node count=0, node count=1) on "__REMOTE_FQS_QUERY__"
- Output: avg(tab1_rep.val)
+ Output: (avg(tab1_rep.val))
Remote query: SELECT pg_catalog.int8_avg(avg(tab1_rep.val)) AS avg FROM ((tab1_rep NATURAL JOIN tab2_rep) NATURAL JOIN tab3_rep) WHERE ((tab1_rep.val > 0) AND (tab2_rep.val < 3))
(3 rows)
@@ -224,15 +224,15 @@ select * from tab3_rep natural join tab4_rep
explain (costs off, num_nodes on, nodes off, verbose on) select * from tab3_rep natural join tab4_rep
where tab3_rep.val > 2 and tab4_rep.val < 5;
- QUERY PLAN
-------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
Nested Loop
Output: tab3_rep.val, tab3_rep.val2
Join Filter: ((tab3_rep.val = tab4_rep.val) AND (tab3_rep.val2 = tab4_rep.val2))
- -> Data Node Scan (primary node count=0, node count=1) on tab3_rep
+ -> Data Node Scan (primary node count=0, node count=1) on tab3_rep "_REMOTE_TABLE_QUERY_"
Output: tab3_rep.val, tab3_rep.val2
Remote query: SELECT val, val2 FROM ONLY tab3_rep WHERE (val > 2)
- -> Data Node Scan (primary node count=0, node count=1) on tab4_rep
+ -> Data Node Scan (primary node count=0, node count=1) on tab4_rep "_REMOTE_TABLE_QUERY_"
Output: tab4_rep.val, tab4_rep.val2
Remote query: SELECT val, val2 FROM ONLY tab4_rep WHERE (val < 5)
(9 rows)
@@ -281,10 +281,10 @@ explain (costs off, verbose on, nodes off) select * from tab1_mod natural join t
Nested Loop
Output: tab1_mod.val, tab1_mod.val2
Join Filter: ((tab1_mod.val = tab4_rep.val) AND (tab1_mod.val2 = tab4_rep.val2))
- -> Data Node Scan on tab1_mod
+ -> Data Node Scan on tab1_mod "_REMOTE_TABLE_QUERY_"
Output: tab1_mod.val, tab1_mod.val2
Remote query: SELECT val, val2 FROM ONLY tab1_mod WHERE (val > 2)
- -> Data Node Scan on tab4_rep
+ -> Data Node Scan on tab4_rep "_REMOTE_TABLE_QUERY_"
Output: tab4_rep.val, tab4_rep.val2
Remote query: SELECT val, val2 FROM ONLY tab4_rep WHERE (val < 4)
(9 rows)
@@ -308,10 +308,10 @@ explain (costs off, verbose on, nodes off) select * from tab1_mod natural join t
Nested Loop
Output: tab1_mod.val, tab1_mod.val2
Join Filter: ((tab1_mod.val = tab2_mod.val) AND (tab1_mod.val2 = tab2_mod.val2))
- -> Data Node Scan on tab1_mod
+ -> Data Node Scan on tab1_mod "_REMOTE_TABLE_QUERY_"
Output: tab1_mod.val, tab1_mod.val2
Remote query: SELECT val, val2 FROM ONLY tab1_mod WHERE (val > 2)
- -> Data Node Scan on tab2_mod
+ -> Data Node Scan on tab2_mod "_REMOTE_TABLE_QUERY_"
Output: tab2_mod.val, tab2_mod.val2
Remote query: SELECT val, val2 FROM ONLY tab2_mod WHERE (val < 4)
(9 rows)
@@ -392,19 +392,15 @@ select * from tab1_mod natural join tab4_rep where tab1_mod.val = 1 order by tab
(5 rows)
explain (costs off, verbose on, nodes off, num_nodes on) select * from tab1_mod natural join tab4_rep where tab1_mod.val = 1 order by tab1_mod.val2;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val2_1_2_1, "__REMOTE_JOIN_QUERY__".val2_1_2_1
Sort Key: "__REMOTE_JOIN_QUERY__".val2_1_2_1
- -> Result
+ -> Data Node Scan (primary node count=0, node count=1) on "__REMOTE_JOIN_QUERY__"
Output: "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val2_1_2_1, "__REMOTE_JOIN_QUERY__".val2_1_2_1
- -> Materialize
- Output: "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val2_1_2_1
- -> Data Node Scan (primary node count=0, node count=1) on "__REMOTE_JOIN_QUERY__"
- Output: "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val2_1_2_1
- Remote query: SELECT in_1.val AS val_1_1_1, in_1.val2 AS val2_1_2_1 FROM (SELECT val, val2 FROM ONLY tab1_mod WHERE (val = 1)) in_1 , (SELECT val, val2 FROM ONLY tab4_rep WHERE (val = 1)) out_1 WHERE (in_1.val2 = out_1.val2)
-(10 rows)
+ Remote query: SELECT in_1.val AS val_1_1_1, in_1.val2 AS val2_1_2_1 FROM (SELECT val, val2 FROM ONLY tab1_mod WHERE (val = 1)) in_1 , (SELECT val, val2 FROM ONLY tab4_rep WHERE (val = 1)) out_1 WHERE (in_1.val2 = out_1.val2)
+(6 rows)
-- following join between distributed tables should get FQSed because both of
-- them reduce to a single node
@@ -421,16 +417,12 @@ select * from tab1_mod join tab2_mod using (val2)
explain (costs off, verbose on, nodes off, num_nodes on) select * from tab1_mod join tab2_mod using (val2)
where tab1_mod.val = 1 and tab2_mod.val = 2 order by tab1_mod.val;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Result
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Data Node Scan (primary node count=0, node count=1) on "__REMOTE_JOIN_QUERY__"
Output: "__REMOTE_JOIN_QUERY__".val2_1_2_1, "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val_2_1_1, "__REMOTE_JOIN_QUERY__".val_1_1_1
- -> Materialize
- Output: "__REMOTE_JOIN_QUERY__".val2_1_2_1, "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val_2_1_1
- -> Data Node Scan (primary node count=0, node count=1) on "__REMOTE_JOIN_QUERY__"
- Output: "__REMOTE_JOIN_QUERY__".val2_1_2_1, "__REMOTE_JOIN_QUERY__".val_1_1_1, "__REMOTE_JOIN_QUERY__".val_2_1_1
- Remote query: SELECT in_1.val2 AS val2_1_2_1, in_1.val AS val_1_1_1, out_1.val AS val_2_1_1 FROM (SELECT val2, val FROM ONLY tab1_mod WHERE (val = 1)) in_1 , (SELECT val, val2 FROM ONLY tab2_mod WHERE (val = 2)) out_1 WHERE (in_1.val2 = out_1.val2)
-(7 rows)
+ Remote query: SELECT in_1.val2 AS val2_1_2_1, in_1.val AS val_1_1_1, out_1.val AS val_2_1_1 FROM (SELECT val2, val FROM ONLY tab1_mod WHERE (val = 1)) in_1 , (SELECT val, val2 FROM ONLY tab2_mod WHERE (val = 2)) out_1 WHERE (in_1.val2 = out_1.val2)
+(3 rows)
-- JOIN involving the distributed table with equi-JOIN on the distributed column
-- with same kind of distribution on same nodes.
@@ -488,10 +480,10 @@ explain (costs off, verbose on, nodes off) update tab1_mod set val2 = 1000 from
-> Nested Loop
Output: tab1_mod.val, 1000, tab1_mod.val, tab1_mod.val2, tab1_mod.ctid, tab1_mod.xc_node_id, tab2_mod.ctid
Join Filter: ((tab1_mod.val = tab2_mod.val) AND (tab1_mod.val2 = tab2_mod.val2))
- -> Data Node Scan on tab1_mod
+ -> Data Node Scan on tab1_mod "_REMOTE_TABLE_QUERY_"
Output: tab1_mod.val, tab1_mod.val2, tab1_mod.ctid, tab1_mod.xc_node_id
Remote query: SELECT val, val2, ctid, xc_node_id FROM ONLY tab1_mod WHERE true
- -> Data Node Scan on tab2_mod
+ -> Data Node Scan on tab2_mod "_REMOTE_TABLE_QUERY_"
Output: tab2_mod.ctid, tab2_mod.val, tab2_mod.val2
Remote query: SELECT ctid, val, val2 FROM ONLY tab2_mod WHERE true
(12 rows)
@@ -505,10 +497,10 @@ explain (costs off, verbose on, nodes off) delete from tab1_mod using tab2_mod
-> Nested Loop
Output: tab1_mod.val, tab1_mod.val2, tab1_mod.ctid, tab1_mod.xc_node_id, tab2_mod.ctid
Join Filter: ((tab1_mod.val = tab2_mod.val) AND (tab1_mod.val2 = tab2_mod.val2))
- -> Data Node Scan on tab1_mod
+ -> Data Node Scan on tab1_mod "_REMOTE_TABLE_QUERY_"
Output: tab1_mod.val, tab1_mod.val2, tab1_mod.ctid, tab1_mod.xc_node_id
Remote query: SELECT val, val2, ctid, xc_node_id FROM ONLY tab1_mod WHERE true
- -> Data Node Scan on tab2_mod
+ -> Data Node Scan on tab2_mod "_REMOTE_TABLE_QUERY_"
Output: tab2_mod.ctid, tab2_mod.val, tab2_mod.val2
Remote query: SELECT ctid, val, val2 FROM ONLY tab2_mod WHERE true
(11 rows)
@@ -522,10 +514,10 @@ explain (costs off, verbose on, nodes off) update tab1_rep set val2 = 1000 from
-> Nested Loop
Output: tab1_rep.val, 1000, tab1_rep.val, tab1_rep.val2, tab1_rep.ctid, tab2_rep.ctid
Join Filter: ((tab1_rep.val = tab2_rep.val) AND (tab1_rep.val2 = tab2_rep.val2))
- -> Data Node Scan on tab1_rep
+ -> Data Node Scan on tab1_rep "_REMOTE_TABLE_QUERY_"
Output: tab1_rep.val, tab1_rep.val2, tab1_rep.ctid
Remote query: SELECT val, val2, ctid FROM ONLY tab1_rep WHERE true
- -> Data Node Scan on tab2_rep
+ -> Data Node Scan on tab2_rep "_REMOTE_TABLE_QUERY_"
Output: tab2_rep.ctid, tab2_rep.val, tab2_rep.val2
Remote query: SELECT ctid, val, val2 FROM ONLY tab2_rep WHERE true
(11 rows)
@@ -539,10 +531,10 @@ explain (costs off, verbose on, nodes off) delete from tab1_rep using tab2_rep
-> Nested Loop
Output: tab1_rep.val, tab1_rep.val2, tab1_rep.ctid, tab2_rep.ctid
Join Filter: ((tab1_rep.val = tab2_rep.val) AND (tab1_rep.val2 = tab2_rep.val2))
- -> Data Node Scan on tab1_rep
+ -> Data Node Scan on tab1_rep "_REMOTE_TABLE_QUERY_"
Output: tab1_rep.val, tab1_rep.val2, tab1_rep.ctid
Remote query: SELECT val, val2, ctid FROM ONLY tab1_rep WHERE true
- -> Data Node Scan on tab2_rep
+ -> Data Node Scan on tab2_rep "_REMOTE_TABLE_QUERY_"
Output: tab2_rep.ctid, tab2_rep.val, tab2_rep.val2
Remote query: SELECT ctid, val, val2 FROM ONLY tab2_rep WHERE true
(11 rows)
diff --git a/src/test/regress/expected/xc_alter_table.out b/src/test/regress/expected/xc_alter_table.out
index 3ee20d03d0..a798e2f8a8 100644
--- a/src/test/regress/expected/xc_alter_table.out
+++ b/src/test/regress/expected/xc_alter_table.out
@@ -79,18 +79,16 @@ SELECT id, name FROM xc_alter_table_1 ORDER BY 1;
-- Check for query generation of remote UPDATE
EXPLAIN (VERBOSE true, COSTS false, NODES false) UPDATE xc_alter_table_1 SET name = 'zzz' WHERE id = currval('xc_alter_table_1_id_seq');
- QUERY PLAN
---------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------
Update on public.xc_alter_table_1
Node expr: xc_alter_table_1.id
Remote query: UPDATE ONLY public.xc_alter_table_1 SET name = $2 WHERE ctid = $5 AND xc_node_id = $6
- -> Result
- Output: id, 'zzz'::character varying(80), NULL::integer, id, ctid, xc_node_id
- -> Data Node Scan on xc_alter_table_1
- Output: id, ctid, xc_node_id
- Remote query: SELECT id, ctid, xc_node_id FROM ONLY xc_alter_table_1 WHERE true
- Coordinator quals: (xc_alter_table_1.id = currval('xc_alter_table_1_id_seq'::regclass))
-(9 rows)
+ -> Data Node Scan on xc_alter_table_1 "_REMOTE_TABLE_QUERY_"
+ Output: xc_alter_table_1.id, 'zzz'::character varying(80), NULL::integer, xc_alter_table_1.id, xc_alter_table_1.ctid, xc_alter_table_1.xc_node_id
+ Remote query: SELECT id, ctid, xc_node_id FROM ONLY xc_alter_table_1 WHERE true
+ Coordinator quals: (xc_alter_table_1.id = currval('xc_alter_table_1_id_seq'::regclass))
+(7 rows)
UPDATE xc_alter_table_1 SET name = 'zzz' WHERE id = currval('xc_alter_table_1_id_seq');
SELECT id, name FROM xc_alter_table_1 ORDER BY 1;
@@ -147,16 +145,14 @@ SELECT b, c FROM xc_alter_table_2 ORDER BY b;
-- Check for query generation of remote UPDATE
EXPLAIN (VERBOSE true, COSTS false, NODES false) UPDATE xc_alter_table_2 SET b = 'Morphee', c = false WHERE b = 'Neo';
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------
Update on public.xc_alter_table_2
Remote query: UPDATE ONLY public.xc_alter_table_2 SET b = $2, c = $3 WHERE ctid = $7
- -> Result
- Output: NULL::integer, 'Morphee'::character varying(20), false, NULL::integer, NULL::integer, b, ctid
- -> Data Node Scan on xc_alter_table_2
- Output: b, ctid
- Remote query: SELECT b, ctid FROM ONLY xc_alter_table_2 WHERE ((b)::text = 'Neo'::text)
-(7 rows)
+ -> Data Node Scan on xc_alter_table_2 "_REMOTE_TABLE_QUERY_"
+ Output: NULL::integer, 'Morphee'::character varying(20), false, NULL::integer, NULL::integer, xc_alter_table_2.b, xc_alter_table_2.ctid
+ Remote query: SELECT b, ctid FROM ONLY xc_alter_table_2 WHERE ((b)::text = 'Neo'::text)
+(5 rows)
UPDATE xc_alter_table_2 SET b = 'Morphee', c = false WHERE b = 'Neo';
SELECT b, c FROM xc_alter_table_2 ORDER BY b;
@@ -194,16 +190,14 @@ SELECT a, a2, b, c FROM xc_alter_table_2 ORDER BY b;
-- Check for query generation of remote UPDATE
EXPLAIN (VERBOSE true, COSTS false, NODES false) UPDATE xc_alter_table_2 SET a = 200, a2 = 'CTO' WHERE b = 'John';
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Update on public.xc_alter_table_2
Remote query: UPDATE ONLY public.xc_alter_table_2 SET a = $6, a2 = $7 WHERE ctid = $9
- -> Result
- Output: NULL::integer, b, c, NULL::integer, NULL::integer, 200, 'CTO'::character varying(20), b, ctid
- -> Data Node Scan on xc_alter_table_2
- Output: b, c, ctid
- Remote query: SELECT b, c, ctid FROM ONLY xc_alter_table_2 WHERE ((b)::text = 'John'::text)
-(7 rows)
+ -> Data Node Scan on xc_alter_table_2 "_REMOTE_TABLE_QUERY_"
+ Output: NULL::integer, xc_alter_table_2.b, xc_alter_table_2.c, NULL::integer, NULL::integer, 200, 'CTO'::character varying(20), xc_alter_table_2.b, xc_alter_table_2.ctid
+ Remote query: SELECT b, c, ctid FROM ONLY xc_alter_table_2 WHERE ((b)::text = 'John'::text)
+(5 rows)
UPDATE xc_alter_table_2 SET a = 200, a2 = 'CTO' WHERE b = 'John';
SELECT a, a2, b, c FROM xc_alter_table_2 ORDER BY b;
diff --git a/src/test/regress/expected/xc_for_update.out b/src/test/regress/expected/xc_for_update.out
index 4c12815e5b..3bed707b16 100644
--- a/src/test/regress/expected/xc_for_update.out
+++ b/src/test/regress/expected/xc_for_update.out
@@ -164,42 +164,42 @@ explain (num_nodes off, nodes off, verbose on) select * from t1, t2 where t1.va
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
Join Filter: (t1.val = t2.val)
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1 NOWAIT
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR UPDATE OF t2 NOWAIT
(11 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 where t1.val = t2.val for update;
- QUERY PLAN
----------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
Join Filter: (t1.val = t2.val)
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR UPDATE OF t2
(11 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 where t1.val = t2.val for share;
- QUERY PLAN
---------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
Join Filter: (t1.val = t2.val)
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR SHARE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR SHARE OF t2
(11 rows)
@@ -213,29 +213,29 @@ explain (num_nodes off, nodes off, verbose on) select * from t1, t2 where t1.va
(3 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2;
- QUERY PLAN
------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------
Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true
(8 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 for update;
- QUERY PLAN
----------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR UPDATE OF t2
(10 rows)
@@ -247,190 +247,188 @@ explain (num_nodes off, nodes off, verbose on) select * from t1, t2 for update
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1 NOWAIT
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR UPDATE OF t2 NOWAIT
(10 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 for share nowait;
- QUERY PLAN
----------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR SHARE OF t1 NOWAIT
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR SHARE OF t2 NOWAIT
(10 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 for share;
- QUERY PLAN
---------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR SHARE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR SHARE OF t2
(10 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 for share of t2;
- QUERY PLAN
---------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=22)
Output: t1.val, t1.val2, t2.val, t2.val2, t1.ctid
-> Nested Loop (cost=0.00..0.01 rows=1 width=22)
Output: t1.val, t1.val2, t2.val, t2.val2, t1.ctid
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=14)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=14)
Output: t1.val, t1.val2, t1.ctid
Remote query: SELECT val, val2, ctid FROM ONLY t1 WHERE true
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR SHARE OF t2
(10 rows)
-- three table case
explain (num_nodes off, nodes off, verbose on) select * from t1, t2, t3;
- QUERY PLAN
------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
Nested Loop (cost=0.00..0.02 rows=1 width=24)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true
- -> Data Node Scan on t3 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t3 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t3.val, t3.val2
Remote query: SELECT val, val2 FROM ONLY t3 WHERE true
(13 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2, t3 for update;
- QUERY PLAN
----------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.03 rows=1 width=24)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2
-> Nested Loop (cost=0.00..0.02 rows=1 width=24)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR UPDATE OF t2
- -> Data Node Scan on t3 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t3 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t3.val, t3.val2
Remote query: SELECT val, val2 FROM ONLY t3 WHERE true FOR UPDATE OF t3
(15 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2, t3 for update of t1;
- QUERY PLAN
----------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.03 rows=1 width=36)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t2.ctid, t3.ctid
-> Nested Loop (cost=0.00..0.02 rows=1 width=36)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t2.ctid, t3.ctid
-> Nested Loop (cost=0.00..0.01 rows=1 width=22)
Output: t1.val, t1.val2, t2.val, t2.val2, t2.ctid
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=14)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=14)
Output: t2.val, t2.val2, t2.ctid
Remote query: SELECT val, val2, ctid FROM ONLY t2 WHERE true
- -> Data Node Scan on t3 (cost=0.00..0.00 rows=1000 width=14)
+ -> Data Node Scan on t3 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=14)
Output: t3.val, t3.val2, t3.ctid
Remote query: SELECT val, val2, ctid FROM ONLY t3 WHERE true
(15 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2, t3 for update of t1,t3;
- QUERY PLAN
----------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.03 rows=1 width=30)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t2.ctid
-> Nested Loop (cost=0.00..0.02 rows=1 width=30)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t2.ctid
-> Nested Loop (cost=0.00..0.01 rows=1 width=22)
Output: t1.val, t1.val2, t2.val, t2.val2, t2.ctid
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=14)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=14)
Output: t2.val, t2.val2, t2.ctid
Remote query: SELECT val, val2, ctid FROM ONLY t2 WHERE true
- -> Data Node Scan on t3 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t3 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t3.val, t3.val2
Remote query: SELECT val, val2 FROM ONLY t3 WHERE true FOR UPDATE OF t3
(15 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2, t3 for update of t1,t3 nowait;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.03 rows=1 width=30)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t2.ctid
-> Nested Loop (cost=0.00..0.02 rows=1 width=30)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t2.ctid
-> Nested Loop (cost=0.00..0.01 rows=1 width=22)
Output: t1.val, t1.val2, t2.val, t2.val2, t2.ctid
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1 NOWAIT
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=14)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=14)
Output: t2.val, t2.val2, t2.ctid
Remote query: SELECT val, val2, ctid FROM ONLY t2 WHERE true
- -> Data Node Scan on t3 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t3 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t3.val, t3.val2
Remote query: SELECT val, val2 FROM ONLY t3 WHERE true FOR UPDATE OF t3 NOWAIT
(15 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1, t2, t3 for share of t1,t2 nowait;
- QUERY PLAN
----------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.03 rows=1 width=30)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t3.ctid
-> Nested Loop (cost=0.00..0.02 rows=1 width=30)
Output: t1.val, t1.val2, t2.val, t2.val2, t3.val, t3.val2, t3.ctid
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR SHARE OF t1 NOWAIT
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR SHARE OF t2 NOWAIT
- -> Data Node Scan on t3 (cost=0.00..0.00 rows=1000 width=14)
+ -> Data Node Scan on t3 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=14)
Output: t3.val, t3.val2, t3.ctid
Remote query: SELECT val, val2, ctid FROM ONLY t3 WHERE true
(15 rows)
-- check a few subquery cases
explain (num_nodes off, nodes off, verbose on) select * from (select * from t1 for update of t1 nowait) as foo;
- QUERY PLAN
-----------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------
LockRows (cost=0.00..10.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Result (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
- Output: t1.val, t1.val2
- Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1 NOWAIT
-(7 rows)
+ Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1 NOWAIT
+(5 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1 where val in (select val from t2 for update of t2 nowait) for update;
QUERY PLAN
@@ -446,17 +444,15 @@ explain (num_nodes off, nodes off, verbose on) select * from t1 where val in (s
Output: "ANY_subquery".*, "ANY_subquery".val
-> LockRows (cost=0.00..10.00 rows=1000 width=4)
Output: t2.val
- -> Result (cost=0.00..0.00 rows=1000 width=4)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=4)
Output: t2.val
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=4)
- Output: t2.val
- Remote query: SELECT val FROM ONLY t2 WHERE true FOR UPDATE OF t2 NOWAIT
+ Remote query: SELECT val FROM ONLY t2 WHERE true FOR UPDATE OF t2 NOWAIT
-> Hash (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
-(21 rows)
+(19 rows)
explain (num_nodes off, nodes off, verbose on) select * from t1 where val in (select val from t2 for update of t2 nowait);
QUERY PLAN
@@ -468,30 +464,28 @@ explain (num_nodes off, nodes off, verbose on) select * from t1 where val in (s
Output: t2.val
-> LockRows (cost=0.00..10.00 rows=1000 width=4)
Output: t2.val
- -> Result (cost=0.00..0.00 rows=1000 width=4)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=4)
Output: t2.val
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=4)
- Output: t2.val
- Remote query: SELECT val FROM ONLY t2 WHERE true FOR UPDATE OF t2 NOWAIT
+ Remote query: SELECT val FROM ONLY t2 WHERE true FOR UPDATE OF t2 NOWAIT
-> Hash (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
-(17 rows)
+(15 rows)
-- test multiple row marks
explain (num_nodes off, nodes off, verbose on) select * from t1, t2 for share of t2 for update of t1;
- QUERY PLAN
----------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: t1.val, t1.val2, t2.val, t2.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR SHARE OF t2
(10 rows)
@@ -540,16 +534,16 @@ explain (num_nodes off, nodes off, verbose on) select * from t1 for share of t1
-- same table , different aliases and different row marks for different aliases
explain (num_nodes off, nodes off, verbose on) select * from t1 a,t1 b for share of a for update of b;
- QUERY PLAN
-----------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
LockRows (cost=0.00..0.02 rows=1 width=16)
Output: a.val, a.val2, b.val, b.val2
-> Nested Loop (cost=0.00..0.01 rows=1 width=16)
Output: a.val, a.val2, b.val, b.val2
- -> Data Node Scan on a (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: a.val, a.val2
Remote query: SELECT val, val2 FROM ONLY t1 a WHERE true FOR SHARE OF a
- -> Data Node Scan on b (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: b.val, b.val2
Remote query: SELECT val, val2 FROM ONLY t1 b WHERE true FOR UPDATE OF b
(10 rows)
@@ -557,68 +551,60 @@ explain (num_nodes off, nodes off, verbose on) select * from t1 a,t1 b for shar
-- test WITH queries
-- join of a WITH table and a normal table
explain (num_nodes off, nodes off, verbose on) WITH q1 AS (SELECT * from t1 FOR UPDATE) SELECT * FROM q1,t2 FOR UPDATE;
- QUERY PLAN
------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------
LockRows (cost=10.00..50.00 rows=1000 width=48)
Output: q1.val, q1.val2, t2.val, t2.val2, q1.*
CTE q1
-> LockRows (cost=0.00..10.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Result (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
- Output: t1.val, t1.val2
- Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
+ Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
-> Nested Loop (cost=0.00..30.00 rows=1000 width=48)
Output: q1.val, q1.val2, t2.val, t2.val2, q1.*
-> CTE Scan on q1 (cost=0.00..20.00 rows=1000 width=40)
Output: q1.val, q1.val2, q1.*
- -> Data Node Scan on t2 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t2 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t2.val, t2.val2
Remote query: SELECT val, val2 FROM ONLY t2 WHERE true FOR UPDATE OF t2
-(17 rows)
+(15 rows)
explain (num_nodes off, nodes off, verbose on) WITH q1 AS (SELECT * from t1) SELECT * FROM q1;
- QUERY PLAN
--------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------
CTE Scan on q1 (cost=0.00..20.00 rows=1000 width=8)
Output: q1.val, q1.val2
CTE q1
- -> Result (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
- Output: t1.val, t1.val2
- Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
-(8 rows)
+ Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
+(6 rows)
-- make sure row marks are no ops for queries on WITH tables
explain (num_nodes off, nodes off, verbose on) WITH q1 AS (SELECT * from t1) SELECT * FROM q1 FOR UPDATE;
- QUERY PLAN
--------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------
CTE Scan on q1 (cost=0.00..20.00 rows=1000 width=8)
Output: q1.val, q1.val2
CTE q1
- -> Result (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
- Output: t1.val, t1.val2
- Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
-(8 rows)
+ Remote query: SELECT val, val2 FROM ONLY t1 WHERE true
+(6 rows)
explain (num_nodes off, nodes off, verbose on) WITH q1 AS (SELECT * from t1 FOR UPDATE) SELECT * FROM q1 FOR UPDATE;
- QUERY PLAN
------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------
CTE Scan on q1 (cost=10.00..30.00 rows=1000 width=8)
Output: q1.val, q1.val2
CTE q1
-> LockRows (cost=0.00..10.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Result (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on t1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: t1.val, t1.val2
- -> Data Node Scan on t1 (cost=0.00..0.00 rows=1000 width=8)
- Output: t1.val, t1.val2
- Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
-(10 rows)
+ Remote query: SELECT val, val2 FROM ONLY t1 WHERE true FOR UPDATE OF t1
+(8 rows)
-- test case of inheried tables
select * from p1 order by 1 for update;
@@ -631,17 +617,17 @@ select * from p1 order by 1 for update;
(4 rows)
explain (num_nodes off, nodes off, verbose on) select * from p1 for update;
- QUERY PLAN
-----------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------
LockRows (cost=0.00..20.00 rows=2000 width=8)
Output: public.p1.a, public.p1.b
-> Result (cost=0.00..0.00 rows=2000 width=8)
Output: public.p1.a, public.p1.b
-> Append (cost=0.00..0.00 rows=2000 width=8)
- -> Data Node Scan on p1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on p1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: public.p1.a, public.p1.b
Remote query: SELECT a, b FROM ONLY p1 WHERE true FOR UPDATE OF p1
- -> Data Node Scan on p1 (cost=0.00..0.00 rows=1000 width=8)
+ -> Data Node Scan on c1 "_REMOTE_TABLE_QUERY_" (cost=0.00..0.00 rows=1000 width=8)
Output: public.p1.a, public.p1.b
Remote query: SELECT a, b FROM ONLY c1 p1 WHERE true
(11 rows)
diff --git a/src/test/regress/expected/xc_groupby.out b/src/test/regress/expected/xc_groupby.out
index 5794d479c1..11ae491e2b 100644
--- a/src/test/regress/expected/xc_groupby.out
+++ b/src/test/regress/expected/xc_groupby.out
@@ -29,12 +29,10 @@ explain (verbose true, costs false, nodes false) select * from (select count(*),
Sort Key: xc_groupby_tab1.val2
-> HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((pg_catalog.sum((sum(xc_groupby_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
-(10 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
+(8 rows)
-- joins and group by
select * from (select count(*), sum(xc_groupby_tab1.val * xc_groupby_tab2.val), avg(xc_groupby_tab1.val*xc_groupby_tab2.val), sum(xc_groupby_tab1.val*xc_groupby_tab2.val)::float8/count(*), xc_groupby_tab1.val2 gt1_val2, xc_groupby_tab2.val2 gt2_val2 from xc_groupby_tab1 full outer join xc_groupby_tab2 on xc_groupby_tab1.val2 = xc_groupby_tab2.val2 group by xc_groupby_tab1.val2, xc_groupby_tab2.val2) q order by q.gt1_val2, q.gt2_val2;
@@ -57,12 +55,12 @@ explain (verbose true, costs false, nodes false) select * from (select count(*),
-> Hash Full Join
Output: xc_groupby_tab1.val, xc_groupby_tab1.val2, xc_groupby_tab2.val, xc_groupby_tab2.val2
Hash Cond: (xc_groupby_tab1.val2 = xc_groupby_tab2.val2)
- -> Data Node Scan on xc_groupby_tab1
+ -> Data Node Scan on xc_groupby_tab1 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab1.val, xc_groupby_tab1.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true
-> Hash
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
- -> Data Node Scan on xc_groupby_tab2
+ -> Data Node Scan on xc_groupby_tab2 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab2 WHERE true
(16 rows)
@@ -76,8 +74,8 @@ select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by va
(2 rows)
explain (verbose true, costs false, nodes false) select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by val2) q1 group by x order by x;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum(q1.y), q1.x
-> Sort
@@ -87,12 +85,10 @@ explain (verbose true, costs false, nodes false) select sum(y) from (select sum(
Output: q1.y, q1.x
-> HashAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), (xc_groupby_tab1.val2 % 2), xc_groupby_tab1.val2
- Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
-(14 rows)
+ Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
+(12 rows)
-- group by without aggregate
select * from (select val2 from xc_groupby_tab1 group by val2) q order by q.val2;
@@ -104,19 +100,17 @@ select * from (select val2 from xc_groupby_tab1 group by val2) q order by q.val2
(3 rows)
explain (verbose true, costs false, nodes false) select * from (select val2 from xc_groupby_tab1 group by val2) q order by q.val2;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------
Sort
Output: xc_groupby_tab1.val2
Sort Key: xc_groupby_tab1.val2
-> HashAggregate
Output: xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_tab1.val2
- Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
-(10 rows)
+ Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
+(8 rows)
select * from (select val + val2 from xc_groupby_tab1 group by val + val2) q order by 1;
?column?
@@ -130,19 +124,17 @@ select * from (select val + val2 from xc_groupby_tab1 group by val + val2) q ord
(6 rows)
explain (verbose true, costs false, nodes false) select * from (select val + val2 from xc_groupby_tab1 group by val + val2) q order by 1;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
Sort Key: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
-> HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2)
- Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
-(10 rows)
+ Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
+(8 rows)
select * from (select val + val2, val, val2 from xc_groupby_tab1 group by val, val2) q order by q.val, q.val2;
?column? | val | val2
@@ -158,19 +150,17 @@ select * from (select val + val2, val, val2 from xc_groupby_tab1 group by val, v
(8 rows)
explain (verbose true, costs false, nodes false) select * from (select val + val2, val, val2 from xc_groupby_tab1 group by val, val2) q order by q.val, q.val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
Sort Key: xc_groupby_tab1.val, xc_groupby_tab1.val2
-> HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2), xc_groupby_tab1.val, xc_groupby_tab1.val2
- Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3
-(10 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3
+(8 rows)
select * from (select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val gt1_val, xc_groupby_tab2.val2 gt2_val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2) q order by q.gt1_val, q.gt2_val2;
?column? | gt1_val | gt2_val2
@@ -184,19 +174,17 @@ select * from (select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab
(6 rows)
explain (verbose true, costs false, nodes false) select * from (select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val gt1_val, xc_groupby_tab2.val2 gt2_val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2) q order by q.gt1_val, q.gt2_val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
Sort Key: xc_groupby_tab1.val, xc_groupby_tab2.val2
-> HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2), xc_groupby_tab1.val, xc_groupby_tab2.val2
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3
-(10 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3
+(8 rows)
select * from (select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2) q order by 1;
?column?
@@ -208,19 +196,17 @@ select * from (select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby
(4 rows)
explain (verbose true, costs false, nodes false) select * from (select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2) q order by 1;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
Sort Key: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
-> HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2)
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1
-(10 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1
+(8 rows)
-- group by with aggregates in expression
select * from (select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2) q order by q.val2;
@@ -232,19 +218,17 @@ select * from (select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1
(3 rows)
explain (verbose true, costs false, nodes false) select * from (select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2) q order by q.val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: ((((pg_catalog.count(*) + pg_catalog.sum((sum(xc_groupby_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_groupby_tab1.val))))), xc_groupby_tab1.val2
Sort Key: xc_groupby_tab1.val2
-> HashAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_groupby_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_groupby_tab1.val)))), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
-(10 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
+(8 rows)
-- group by with expressions in group by clause
select * from (select sum(val), avg(val), 2 * val2 expr from xc_groupby_tab1 group by 2 * val2) q order by q.expr;
@@ -256,19 +240,17 @@ select * from (select sum(val), avg(val), 2 * val2 expr from xc_groupby_tab1 gro
(3 rows)
explain (verbose true, costs false, nodes false) select * from (select sum(val), avg(val), 2 * val2 expr from xc_groupby_tab1 group by 2 * val2) q order by q.expr;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: (pg_catalog.sum((sum(xc_groupby_tab1.val)))), (pg_catalog.avg((avg(xc_groupby_tab1.val)))), ((2 * xc_groupby_tab1.val2))
Sort Key: ((2 * xc_groupby_tab1.val2))
-> HashAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((2 * xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), ((2 * xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), (2 * xc_groupby_tab1.val2)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
-(10 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
+(8 rows)
drop table xc_groupby_tab1;
drop table xc_groupby_tab2;
@@ -297,19 +279,17 @@ select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b
(4 rows)
explain (verbose true, costs false, nodes false) select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b) q order by q.b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: (pg_catalog.avg((avg(xc_groupby_def.a)))), (pg_catalog.sum((sum(xc_groupby_def.a)))), (pg_catalog.count(*)), xc_groupby_def.b
Sort Key: xc_groupby_def.b
-> HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_def.a))), pg_catalog.sum((sum(xc_groupby_def.a))), pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_def.a)), (sum(xc_groupby_def.a)), (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_def.a), sum(xc_groupby_def.a), count(*), xc_groupby_def.b
- Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4
-(10 rows)
+ Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4
+(8 rows)
select b from xc_groupby_def group by b;
b
@@ -321,16 +301,14 @@ select b from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b from xc_groupby_def group by b;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b
- Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
-(7 rows)
+ Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
+(5 rows)
select b,count(b) from xc_groupby_def group by b;
b | count
@@ -342,16 +320,14 @@ select b,count(b) from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b,count(b) from xc_groupby_def group by b;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_groupby_def.b, count((count(xc_groupby_def.b)))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b, (count(xc_groupby_def.b))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b, count(xc_groupby_def.b)
- Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
-(7 rows)
+ Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
+(5 rows)
select count(*) from xc_groupby_def where b is null group by b;
count
@@ -360,16 +336,14 @@ select count(*) from xc_groupby_def where b is null group by b;
(1 row)
explain (verbose true, costs false, nodes false) select count(*) from xc_groupby_def where b is null group by b;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), xc_groupby_def.b
- Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2
+(5 rows)
create table xc_groupby_g(a int, b float, c numeric);
insert into xc_groupby_g values(1,2.1,3.2);
@@ -383,16 +357,14 @@ select sum(a) from xc_groupby_g group by a;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(a) from xc_groupby_g group by a;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.sum((sum(xc_groupby_g.a))), xc_groupby_g.a
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.a)), xc_groupby_g.a
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.a), xc_groupby_g.a
- Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select sum(b) from xc_groupby_g group by b;
sum
@@ -402,16 +374,14 @@ select sum(b) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(b) from xc_groupby_g group by b;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: sum((sum(xc_groupby_g.b))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.b)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.b), xc_groupby_g.b
- Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select sum(c) from xc_groupby_g group by b;
sum
@@ -421,16 +391,14 @@ select sum(c) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(c) from xc_groupby_g group by b;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: sum((sum(xc_groupby_g.c))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.c)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.c), xc_groupby_g.b
- Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select avg(a) from xc_groupby_g group by b;
avg
@@ -440,16 +408,14 @@ select avg(a) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(a) from xc_groupby_g group by b;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.a))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.a)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.a), xc_groupby_g.b
- Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select avg(b) from xc_groupby_g group by c;
avg
@@ -459,16 +425,14 @@ select avg(b) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(b) from xc_groupby_g group by c;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.b))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.b)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.b), xc_groupby_g.c
- Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select avg(c) from xc_groupby_g group by c;
avg
@@ -478,16 +442,14 @@ select avg(c) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(c) from xc_groupby_g group by c;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.c))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.c)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.c), xc_groupby_g.c
- Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
drop table xc_groupby_def;
drop table xc_groupby_g;
@@ -511,12 +473,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((pg_catalog.sum((sum(xc_groupby_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
+(5 rows)
-- joins and group by
select count(*), sum(xc_groupby_tab1.val * xc_groupby_tab2.val), avg(xc_groupby_tab1.val*xc_groupby_tab2.val), sum(xc_groupby_tab1.val*xc_groupby_tab2.val)::float8/count(*), xc_groupby_tab1.val2, xc_groupby_tab2.val2 from xc_groupby_tab1 full outer join xc_groupby_tab2 on xc_groupby_tab1.val2 = xc_groupby_tab2.val2 group by xc_groupby_tab1.val2, xc_groupby_tab2.val2;
@@ -536,12 +496,12 @@ explain (verbose true, costs false, nodes false) select count(*), sum(xc_groupby
-> Hash Full Join
Output: xc_groupby_tab1.val, xc_groupby_tab1.val2, xc_groupby_tab2.val, xc_groupby_tab2.val2
Hash Cond: (xc_groupby_tab1.val2 = xc_groupby_tab2.val2)
- -> Data Node Scan on xc_groupby_tab1
+ -> Data Node Scan on xc_groupby_tab1 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab1.val, xc_groupby_tab1.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true
-> Hash
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
- -> Data Node Scan on xc_groupby_tab2
+ -> Data Node Scan on xc_groupby_tab2 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab2 WHERE true
(13 rows)
@@ -555,18 +515,16 @@ select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by va
(2 rows)
explain (verbose true, costs false, nodes false) select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by val2) q1 group by x;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: sum((pg_catalog.sum((sum(xc_groupby_tab1.val))))), ((xc_groupby_tab1.val2 % 2))
-> HashAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), (xc_groupby_tab1.val2 % 2), xc_groupby_tab1.val2
- Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
-(9 rows)
+ Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
+(7 rows)
-- group by without aggregate
select val2 from xc_groupby_tab1 group by val2;
@@ -578,16 +536,14 @@ select val2 from xc_groupby_tab1 group by val2;
(3 rows)
explain (verbose true, costs false, nodes false) select val2 from xc_groupby_tab1 group by val2;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_tab1.val2
- Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
-(7 rows)
+ Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
+(5 rows)
select val + val2 from xc_groupby_tab1 group by val + val2;
?column?
@@ -601,16 +557,14 @@ select val + val2 from xc_groupby_tab1 group by val + val2;
(6 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_groupby_tab1 group by val + val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2)
- Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
-(7 rows)
+ Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1
+(5 rows)
select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
?column? | val | val2
@@ -626,16 +580,14 @@ select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
(8 rows)
explain (verbose true, costs false, nodes false) select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2), xc_groupby_tab1.val, xc_groupby_tab1.val2
- Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3
-(7 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3
+(5 rows)
select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2;
?column? | val | val2
@@ -649,16 +601,14 @@ select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_group
(6 rows)
explain (verbose true, costs false, nodes false) select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2), xc_groupby_tab1.val, xc_groupby_tab2.val2
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3
-(7 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3
+(5 rows)
select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2;
?column?
@@ -670,16 +620,14 @@ select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_group
(4 rows)
explain (verbose true, costs false, nodes false) select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2)
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1
-(7 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1
+(5 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
@@ -691,16 +639,14 @@ select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
(3 rows)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_groupby_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_groupby_tab1.val)))), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4
+(5 rows)
-- group by with expressions in group by clause
select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
@@ -712,16 +658,14 @@ select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
(3 rows)
explain (verbose true, costs false, nodes false) select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((2 * xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), ((2 * xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), (2 * xc_groupby_tab1.val2)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
-(7 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3
+(5 rows)
drop table xc_groupby_tab1;
drop table xc_groupby_tab2;
@@ -750,19 +694,17 @@ select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b
(4 rows)
explain (verbose true, costs false, nodes false) select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b) q order by q.b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort
Output: (pg_catalog.avg((avg(xc_groupby_def.a)))), (pg_catalog.sum((sum(xc_groupby_def.a)))), (pg_catalog.count(*)), xc_groupby_def.b
Sort Key: xc_groupby_def.b
-> HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_def.a))), pg_catalog.sum((sum(xc_groupby_def.a))), pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_def.a)), (sum(xc_groupby_def.a)), (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_def.a), sum(xc_groupby_def.a), count(*), xc_groupby_def.b
- Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4
-(10 rows)
+ Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4
+(8 rows)
select b from xc_groupby_def group by b;
b
@@ -774,16 +716,14 @@ select b from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b from xc_groupby_def group by b;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b
- Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
-(7 rows)
+ Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
+(5 rows)
select b,count(b) from xc_groupby_def group by b;
b | count
@@ -795,16 +735,14 @@ select b,count(b) from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b,count(b) from xc_groupby_def group by b;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_groupby_def.b, count((count(xc_groupby_def.b)))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b, (count(xc_groupby_def.b))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b, count(xc_groupby_def.b)
- Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
-(7 rows)
+ Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1
+(5 rows)
select count(*) from xc_groupby_def where b is null group by b;
count
@@ -813,16 +751,14 @@ select count(*) from xc_groupby_def where b is null group by b;
(1 row)
explain (verbose true, costs false, nodes false) select count(*) from xc_groupby_def where b is null group by b;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), xc_groupby_def.b
- Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2
+(5 rows)
create table xc_groupby_g(a int, b float, c numeric) distribute by replication;
insert into xc_groupby_g values(1,2.1,3.2);
@@ -836,16 +772,14 @@ select sum(a) from xc_groupby_g group by a;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(a) from xc_groupby_g group by a;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.sum((sum(xc_groupby_g.a))), xc_groupby_g.a
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.a)), xc_groupby_g.a
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.a), xc_groupby_g.a
- Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select sum(b) from xc_groupby_g group by b;
sum
@@ -855,16 +789,14 @@ select sum(b) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(b) from xc_groupby_g group by b;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: sum((sum(xc_groupby_g.b))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.b)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.b), xc_groupby_g.b
- Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select sum(c) from xc_groupby_g group by b;
sum
@@ -874,16 +806,14 @@ select sum(c) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(c) from xc_groupby_g group by b;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: sum((sum(xc_groupby_g.c))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.c)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.c), xc_groupby_g.b
- Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select avg(a) from xc_groupby_g group by b;
avg
@@ -893,16 +823,14 @@ select avg(a) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(a) from xc_groupby_g group by b;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.a))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.a)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.a), xc_groupby_g.b
- Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select avg(b) from xc_groupby_g group by c;
avg
@@ -912,16 +840,14 @@ select avg(b) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(b) from xc_groupby_g group by c;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.b))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.b)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.b), xc_groupby_g.c
- Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
select avg(c) from xc_groupby_g group by c;
avg
@@ -931,16 +857,14 @@ select avg(c) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(c) from xc_groupby_g group by c;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.c))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.c)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.c), xc_groupby_g.c
- Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2
+(5 rows)
drop table xc_groupby_def;
drop table xc_groupby_g;
@@ -965,12 +889,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((pg_catalog.sum((sum(xc_groupby_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
-- joins and group by
select count(*), sum(xc_groupby_tab1.val * xc_groupby_tab2.val), avg(xc_groupby_tab1.val*xc_groupby_tab2.val), sum(xc_groupby_tab1.val*xc_groupby_tab2.val)::float8/count(*), xc_groupby_tab1.val2, xc_groupby_tab2.val2 from xc_groupby_tab1 full outer join xc_groupby_tab2 on xc_groupby_tab1.val2 = xc_groupby_tab2.val2 group by xc_groupby_tab1.val2, xc_groupby_tab2.val2;
@@ -993,12 +915,12 @@ explain (verbose true, costs false, nodes false) select count(*), sum(xc_groupby
-> Hash Full Join
Output: xc_groupby_tab1.val, xc_groupby_tab2.val, xc_groupby_tab1.val2, xc_groupby_tab2.val2
Hash Cond: (xc_groupby_tab1.val2 = xc_groupby_tab2.val2)
- -> Data Node Scan on xc_groupby_tab1
+ -> Data Node Scan on xc_groupby_tab1 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab1.val, xc_groupby_tab1.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true
-> Hash
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
- -> Data Node Scan on xc_groupby_tab2
+ -> Data Node Scan on xc_groupby_tab2 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab2 WHERE true
(16 rows)
@@ -1012,8 +934,8 @@ select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by va
(2 rows)
explain (verbose true, costs false, nodes false) select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by val2) q1 group by x;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum(q1.y), q1.x
-> Sort
@@ -1023,12 +945,10 @@ explain (verbose true, costs false, nodes false) select sum(y) from (select sum(
Output: q1.y, q1.x
-> GroupAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), (xc_groupby_tab1.val2 % 2), xc_groupby_tab1.val2
- Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
-(14 rows)
+ Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
+(12 rows)
-- group by without aggregate
select val2 from xc_groupby_tab1 group by val2;
@@ -1040,16 +960,14 @@ select val2 from xc_groupby_tab1 group by val2;
(3 rows)
explain (verbose true, costs false, nodes false) select val2 from xc_groupby_tab1 group by val2;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
Group
Output: xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_tab1.val2
- Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select val + val2 from xc_groupby_tab1 group by val + val2;
?column?
@@ -1063,16 +981,14 @@ select val + val2 from xc_groupby_tab1 group by val + val2;
(6 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_groupby_tab1 group by val + val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2)
- Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
?column? | val | val2
@@ -1088,16 +1004,14 @@ select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
(8 rows)
explain (verbose true, costs false, nodes false) select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2), xc_groupby_tab1.val, xc_groupby_tab1.val2
- Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3 ORDER BY 2, 3
-(7 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3 ORDER BY 2, 3
+(5 rows)
select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2;
?column? | val | val2
@@ -1111,16 +1025,14 @@ select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_group
(6 rows)
explain (verbose true, costs false, nodes false) select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2), xc_groupby_tab1.val, xc_groupby_tab2.val2
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3 ORDER BY 2, 3
-(7 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3 ORDER BY 2, 3
+(5 rows)
select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2;
?column?
@@ -1132,16 +1044,14 @@ select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_group
(4 rows)
explain (verbose true, costs false, nodes false) select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2)
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1 ORDER BY 1
+(5 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
@@ -1153,16 +1063,14 @@ select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
(3 rows)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_groupby_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_groupby_tab1.val)))), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
-- group by with expressions in group by clause
select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
@@ -1174,16 +1082,14 @@ select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
(3 rows)
explain (verbose true, costs false, nodes false) select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((2 * xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), ((2 * xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), (2 * xc_groupby_tab1.val2)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
-(7 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
+(5 rows)
drop table xc_groupby_tab1;
drop table xc_groupby_tab2;
@@ -1212,16 +1118,14 @@ select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b
(4 rows)
explain (verbose true, costs false, nodes false) select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b) q order by q.b;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_def.a))), pg_catalog.sum((sum(xc_groupby_def.a))), pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_def.a)), (sum(xc_groupby_def.a)), (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_def.a), sum(xc_groupby_def.a), count(*), xc_groupby_def.b
- Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
select b from xc_groupby_def group by b;
b
@@ -1233,16 +1137,14 @@ select b from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b from xc_groupby_def group by b;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------
Group
Output: xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b
- Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select b,count(b) from xc_groupby_def group by b;
b | count
@@ -1254,16 +1156,14 @@ select b,count(b) from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b,count(b) from xc_groupby_def group by b;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: xc_groupby_def.b, count((count(xc_groupby_def.b)))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b, (count(xc_groupby_def.b))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b, count(xc_groupby_def.b)
- Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select count(*) from xc_groupby_def where b is null group by b;
count
@@ -1272,16 +1172,14 @@ select count(*) from xc_groupby_def where b is null group by b;
(1 row)
explain (verbose true, costs false, nodes false) select count(*) from xc_groupby_def where b is null group by b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), xc_groupby_def.b
- Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
create table xc_groupby_g(a int, b float, c numeric);
insert into xc_groupby_g values(1,2.1,3.2);
@@ -1295,16 +1193,14 @@ select sum(a) from xc_groupby_g group by a;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(a) from xc_groupby_g group by a;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(xc_groupby_g.a))), xc_groupby_g.a
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.a)), xc_groupby_g.a
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.a), xc_groupby_g.a
- Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select sum(b) from xc_groupby_g group by b;
sum
@@ -1314,16 +1210,14 @@ select sum(b) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(b) from xc_groupby_g group by b;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum((sum(xc_groupby_g.b))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.b)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.b), xc_groupby_g.b
- Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select sum(c) from xc_groupby_g group by b;
sum
@@ -1333,16 +1227,14 @@ select sum(c) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(c) from xc_groupby_g group by b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum((sum(xc_groupby_g.c))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.c)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.c), xc_groupby_g.b
- Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select avg(a) from xc_groupby_g group by b;
avg
@@ -1352,16 +1244,14 @@ select avg(a) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(a) from xc_groupby_g group by b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.a))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.a)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.a), xc_groupby_g.b
- Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select avg(b) from xc_groupby_g group by c;
avg
@@ -1371,16 +1261,14 @@ select avg(b) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(b) from xc_groupby_g group by c;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.b))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.b)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.b), xc_groupby_g.c
- Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select avg(c) from xc_groupby_g group by c;
avg
@@ -1390,16 +1278,14 @@ select avg(c) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(c) from xc_groupby_g group by c;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.c))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.c)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.c), xc_groupby_g.c
- Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
drop table xc_groupby_def;
drop table xc_groupby_g;
@@ -1423,12 +1309,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((pg_catalog.sum((sum(xc_groupby_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
-- joins and group by
select count(*), sum(xc_groupby_tab1.val * xc_groupby_tab2.val), avg(xc_groupby_tab1.val*xc_groupby_tab2.val), sum(xc_groupby_tab1.val*xc_groupby_tab2.val)::float8/count(*), xc_groupby_tab1.val2, xc_groupby_tab2.val2 from xc_groupby_tab1 full outer join xc_groupby_tab2 on xc_groupby_tab1.val2 = xc_groupby_tab2.val2 group by xc_groupby_tab1.val2, xc_groupby_tab2.val2;
@@ -1451,12 +1335,12 @@ explain (verbose true, costs false, nodes false) select count(*), sum(xc_groupby
-> Hash Full Join
Output: xc_groupby_tab1.val, xc_groupby_tab2.val, xc_groupby_tab1.val2, xc_groupby_tab2.val2
Hash Cond: (xc_groupby_tab1.val2 = xc_groupby_tab2.val2)
- -> Data Node Scan on xc_groupby_tab1
+ -> Data Node Scan on xc_groupby_tab1 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab1.val, xc_groupby_tab1.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true
-> Hash
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
- -> Data Node Scan on xc_groupby_tab2
+ -> Data Node Scan on xc_groupby_tab2 "_REMOTE_TABLE_QUERY_"
Output: xc_groupby_tab2.val, xc_groupby_tab2.val2
Remote query: SELECT val, val2 FROM ONLY xc_groupby_tab2 WHERE true
(16 rows)
@@ -1470,8 +1354,8 @@ select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by va
(2 rows)
explain (verbose true, costs false, nodes false) select sum(y) from (select sum(val) y, val2%2 x from xc_groupby_tab1 group by val2) q1 group by x;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum(q1.y), q1.x
-> Sort
@@ -1481,12 +1365,10 @@ explain (verbose true, costs false, nodes false) select sum(y) from (select sum(
Output: q1.y, q1.x
-> GroupAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), ((xc_groupby_tab1.val2 % 2)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), (xc_groupby_tab1.val2 % 2), xc_groupby_tab1.val2
- Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
-(14 rows)
+ Remote query: SELECT sum(group_1.val), (group_1.val2 % 2), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
+(12 rows)
-- group by without aggregate
select val2 from xc_groupby_tab1 group by val2;
@@ -1498,16 +1380,14 @@ select val2 from xc_groupby_tab1 group by val2;
(3 rows)
explain (verbose true, costs false, nodes false) select val2 from xc_groupby_tab1 group by val2;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
Group
Output: xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_tab1.val2
- Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT group_1.val2 FROM (SELECT val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select val + val2 from xc_groupby_tab1 group by val + val2;
?column?
@@ -1521,16 +1401,14 @@ select val + val2 from xc_groupby_tab1 group by val + val2;
(6 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_groupby_tab1 group by val + val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2)
- Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT (group_1.val + group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
?column? | val | val2
@@ -1546,16 +1424,14 @@ select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
(8 rows)
explain (verbose true, costs false, nodes false) select val + val2, val, val2 from xc_groupby_tab1 group by val, val2;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab1.val2)), xc_groupby_tab1.val, xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab1.val2), xc_groupby_tab1.val, xc_groupby_tab1.val2
- Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3 ORDER BY 2, 3
-(7 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), group_1.val, group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 2, 3 ORDER BY 2, 3
+(5 rows)
select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2;
?column? | val | val2
@@ -1569,16 +1445,14 @@ select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_group
(6 rows)
explain (verbose true, costs false, nodes false) select xc_groupby_tab1.val + xc_groupby_tab2.val2, xc_groupby_tab1.val, xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val, xc_groupby_tab2.val2;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2)), xc_groupby_tab1.val, xc_groupby_tab2.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2), xc_groupby_tab1.val, xc_groupby_tab2.val2
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3 ORDER BY 2, 3
-(7 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1), group_2.val_1_1_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 2, 3 ORDER BY 2, 3
+(5 rows)
select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2;
?column?
@@ -1590,16 +1464,14 @@ select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_group
(4 rows)
explain (verbose true, costs false, nodes false) select xc_groupby_tab1.val + xc_groupby_tab2.val2 from xc_groupby_tab1, xc_groupby_tab2 where xc_groupby_tab1.val = xc_groupby_tab2.val group by xc_groupby_tab1.val + xc_groupby_tab2.val2;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Group
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_groupby_tab1.val + xc_groupby_tab2.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_groupby_tab1.val + xc_groupby_tab2.val2)
- Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT (group_2.val_1_1_1 + group_2.val2_2_2_1) FROM (SELECT in_1.val AS val_1_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val FROM ONLY xc_groupby_tab1 WHERE true) in_1 , (SELECT val2, val FROM ONLY xc_groupby_tab2 WHERE true) out_1 WHERE (in_1.val = out_1.val)) group_2 GROUP BY 1 ORDER BY 1
+(5 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
@@ -1611,16 +1483,14 @@ select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
(3 rows)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_groupby_tab1 group by val2;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_groupby_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_groupby_tab1.val)))), xc_groupby_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), xc_groupby_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), xc_groupby_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
-- group by with expressions in group by clause
select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
@@ -1632,16 +1502,14 @@ select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
(3 rows)
explain (verbose true, costs false, nodes false) select sum(val), avg(val), 2 * val2 from xc_groupby_tab1 group by 2 * val2;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(xc_groupby_tab1.val))), pg_catalog.avg((avg(xc_groupby_tab1.val))), ((2 * xc_groupby_tab1.val2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_tab1.val)), (avg(xc_groupby_tab1.val)), ((2 * xc_groupby_tab1.val2))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_tab1.val), avg(xc_groupby_tab1.val), (2 * xc_groupby_tab1.val2)
- Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
-(7 rows)
+ Remote query: SELECT sum(group_1.val), avg(group_1.val), (2 * group_1.val2) FROM (SELECT val, val2 FROM ONLY xc_groupby_tab1 WHERE true) group_1 GROUP BY 3 ORDER BY 3
+(5 rows)
drop table xc_groupby_tab1;
drop table xc_groupby_tab2;
@@ -1670,16 +1538,14 @@ select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b
(4 rows)
explain (verbose true, costs false, nodes false) select * from (select avg(a), sum(a), count(*), b from xc_groupby_def group by b) q order by q.b;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_def.a))), pg_catalog.sum((sum(xc_groupby_def.a))), pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_def.a)), (sum(xc_groupby_def.a)), (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_def.a), sum(xc_groupby_def.a), count(*), xc_groupby_def.b
- Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT avg(group_1.a), sum(group_1.a), count(*), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
select b from xc_groupby_def group by b;
b
@@ -1691,16 +1557,14 @@ select b from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b from xc_groupby_def group by b;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------
Group
Output: xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b
- Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select b,count(b) from xc_groupby_def group by b;
b | count
@@ -1712,16 +1576,14 @@ select b,count(b) from xc_groupby_def group by b;
(4 rows)
explain (verbose true, costs false, nodes false) select b,count(b) from xc_groupby_def group by b;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: xc_groupby_def.b, count((count(xc_groupby_def.b)))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_groupby_def.b, (count(xc_groupby_def.b))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_groupby_def.b, count(xc_groupby_def.b)
- Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(7 rows)
+ Remote query: SELECT group_1.b, count(group_1.b) FROM (SELECT b FROM ONLY xc_groupby_def WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(5 rows)
select count(*) from xc_groupby_def where b is null group by b;
count
@@ -1730,16 +1592,14 @@ select count(*) from xc_groupby_def where b is null group by b;
(1 row)
explain (verbose true, costs false, nodes false) select count(*) from xc_groupby_def where b is null group by b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), xc_groupby_def.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), xc_groupby_def.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), xc_groupby_def.b
- Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT count(*), group_1.b FROM (SELECT b FROM ONLY xc_groupby_def WHERE (b IS NULL)) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
create table xc_groupby_g(a int, b float, c numeric) distribute by replication;
insert into xc_groupby_g values(1,2.1,3.2);
@@ -1753,16 +1613,14 @@ select sum(a) from xc_groupby_g group by a;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(a) from xc_groupby_g group by a;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.sum((sum(xc_groupby_g.a))), xc_groupby_g.a
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.a)), xc_groupby_g.a
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.a), xc_groupby_g.a
- Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.a), group_1.a FROM (SELECT a FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select sum(b) from xc_groupby_g group by b;
sum
@@ -1772,16 +1630,14 @@ select sum(b) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(b) from xc_groupby_g group by b;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum((sum(xc_groupby_g.b))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.b)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.b), xc_groupby_g.b
- Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.b), group_1.b FROM (SELECT b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select sum(c) from xc_groupby_g group by b;
sum
@@ -1791,16 +1647,14 @@ select sum(c) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select sum(c) from xc_groupby_g group by b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: sum((sum(xc_groupby_g.c))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (sum(xc_groupby_g.c)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: sum(xc_groupby_g.c), xc_groupby_g.b
- Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT sum(group_1.c), group_1.b FROM (SELECT c, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select avg(a) from xc_groupby_g group by b;
avg
@@ -1810,16 +1664,14 @@ select avg(a) from xc_groupby_g group by b;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(a) from xc_groupby_g group by b;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.a))), xc_groupby_g.b
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.a)), xc_groupby_g.b
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.a), xc_groupby_g.b
- Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.a), group_1.b FROM (SELECT a, b FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select avg(b) from xc_groupby_g group by c;
avg
@@ -1829,16 +1681,14 @@ select avg(b) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(b) from xc_groupby_g group by c;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.b))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.b)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.b), xc_groupby_g.c
- Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.b), group_1.c FROM (SELECT b, c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
select avg(c) from xc_groupby_g group by c;
avg
@@ -1848,16 +1698,14 @@ select avg(c) from xc_groupby_g group by c;
(2 rows)
explain (verbose true, costs false, nodes false) select avg(c) from xc_groupby_g group by c;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.avg((avg(xc_groupby_g.c))), xc_groupby_g.c
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (avg(xc_groupby_g.c)), xc_groupby_g.c
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: avg(xc_groupby_g.c), xc_groupby_g.c
- Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
-(7 rows)
+ Remote query: SELECT avg(group_1.c), group_1.c FROM (SELECT c FROM ONLY xc_groupby_g WHERE true) group_1 GROUP BY 2 ORDER BY 2
+(5 rows)
drop table xc_groupby_def;
drop table xc_groupby_g;
diff --git a/src/test/regress/expected/xc_having.out b/src/test/regress/expected/xc_having.out
index 31e255fb65..6f9aba40f8 100644
--- a/src/test/regress/expected/xc_having.out
+++ b/src/test/regress/expected/xc_having.out
@@ -25,12 +25,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4
+(5 rows)
-- having clause containing aggregate
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75;
@@ -45,12 +43,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 or val2 > 2;
count | sum | avg | ?column? | val2
@@ -65,12 +61,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: ((pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75) OR (xc_having_tab1.val2 > 2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 and val2 > 2;
count | sum | avg | ?column? | val2
@@ -83,12 +77,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4
+(6 rows)
-- joins and group by and having
select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab1.val*xc_having_tab2.val), sum(xc_having_tab1.val*xc_having_tab2.val)::float8/count(*), xc_having_tab1.val2, xc_having_tab2.val2 from xc_having_tab1 full outer join xc_having_tab2 on xc_having_tab1.val2 = xc_having_tab2.val2 group by xc_having_tab1.val2, xc_having_tab2.val2 having xc_having_tab1.val2 + xc_having_tab2.val2 > 2;
@@ -105,10 +97,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(xc_having_
-> Nested Loop
Output: xc_having_tab1.val, xc_having_tab1.val2, xc_having_tab2.val, xc_having_tab2.val2
Join Filter: ((xc_having_tab1.val2 = xc_having_tab2.val2) AND ((xc_having_tab1.val2 + xc_having_tab2.val2) > 2))
- -> Data Node Scan on xc_having_tab1
+ -> Data Node Scan on xc_having_tab1 "_REMOTE_TABLE_QUERY_"
Output: xc_having_tab1.val, xc_having_tab1.val2
Remote query: SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true
- -> Data Node Scan on xc_having_tab2
+ -> Data Node Scan on xc_having_tab2 "_REMOTE_TABLE_QUERY_"
Output: xc_having_tab2.val, xc_having_tab2.val2
Remote query: SELECT val, val2 FROM ONLY xc_having_tab2 WHERE true
(11 rows)
@@ -121,17 +113,15 @@ select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
(1 row)
explain (verbose true, costs false, nodes false) select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_having_tab1.val2
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 8)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_having_tab1.val2, (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_having_tab1.val2, sum(xc_having_tab1.val)
- Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
-(8 rows)
+ Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
+(6 rows)
select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
?column?
@@ -142,17 +132,15 @@ select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
(3 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: ((xc_having_tab1.val + xc_having_tab1.val2))
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 5)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_having_tab1.val + xc_having_tab1.val2)), (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_having_tab1.val + xc_having_tab1.val2), sum(xc_having_tab1.val)
- Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
-(8 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
+(6 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
@@ -162,17 +150,15 @@ select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 ha
(1 row)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_having_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_having_tab1.val)))), xc_having_tab1.val2
Filter: (min((min(xc_having_tab1.val))) < xc_having_tab1.val2)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2, (min(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2, min(xc_having_tab1.val)
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
+(6 rows)
drop table xc_having_tab1;
drop table xc_having_tab2;
@@ -195,12 +181,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4
+(5 rows)
-- having clause containing aggregate
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75;
@@ -215,12 +199,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 or val2 > 2;
count | sum | avg | ?column? | val2
@@ -235,12 +217,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: ((pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75) OR (xc_having_tab1.val2 > 2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 and val2 > 2;
count | sum | avg | ?column? | val2
@@ -253,12 +233,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4
+(6 rows)
-- joins and group by and having
select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab1.val*xc_having_tab2.val), sum(xc_having_tab1.val*xc_having_tab2.val)::float8/count(*), xc_having_tab1.val2, xc_having_tab2.val2 from xc_having_tab1 full outer join xc_having_tab2 on xc_having_tab1.val2 = xc_having_tab2.val2 group by xc_having_tab1.val2, xc_having_tab2.val2 having xc_having_tab1.val2 + xc_having_tab2.val2 > 2;
@@ -268,16 +246,14 @@ select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab
(1 row)
explain (verbose true, costs false, nodes false) select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab1.val*xc_having_tab2.val), sum(xc_having_tab1.val*xc_having_tab2.val)::float8/count(*), xc_having_tab1.val2, xc_having_tab2.val2 from xc_having_tab1 full outer join xc_having_tab2 on xc_having_tab1.val2 = xc_having_tab2.val2 group by xc_having_tab1.val2, xc_having_tab2.val2 having xc_having_tab1.val2 + xc_having_tab2.val2 > 2;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum((xc_having_tab1.val * xc_having_tab2.val)))), pg_catalog.avg((avg((xc_having_tab1.val * xc_having_tab2.val)))), ((pg_catalog.sum((sum((xc_having_tab1.val * xc_having_tab2.val)))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2, xc_having_tab2.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum((xc_having_tab1.val * xc_having_tab2.val))), (avg((xc_having_tab1.val * xc_having_tab2.val))), xc_having_tab1.val2, xc_having_tab2.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum((xc_having_tab1.val * xc_having_tab2.val)), avg((xc_having_tab1.val * xc_having_tab2.val)), xc_having_tab1.val2, xc_having_tab2.val2
- Remote query: SELECT count(*), sum((group_2.val_1_1_1 * group_2.val_2_1_1)), avg((group_2.val_1_1_1 * group_2.val_2_1_1)), group_2.val2_1_2_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, in_1.val2 AS val2_1_2_1, out_1.val AS val_2_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) in_1 , (SELECT val, val2 FROM ONLY xc_having_tab2 WHERE true) out_1 WHERE ((in_1.val2 = out_1.val2) AND ((in_1.val2 + out_1.val2) > 2))) group_2 GROUP BY 4, 5
-(7 rows)
+ Remote query: SELECT count(*), sum((group_2.val_1_1_1 * group_2.val_2_1_1)), avg((group_2.val_1_1_1 * group_2.val_2_1_1)), group_2.val2_1_2_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, in_1.val2 AS val2_1_2_1, out_1.val AS val_2_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) in_1 , (SELECT val, val2 FROM ONLY xc_having_tab2 WHERE true) out_1 WHERE ((in_1.val2 = out_1.val2) AND ((in_1.val2 + out_1.val2) > 2))) group_2 GROUP BY 4, 5
+(5 rows)
-- group by and having, without aggregate in the target list
select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
@@ -287,17 +263,15 @@ select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
(1 row)
explain (verbose true, costs false, nodes false) select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
- QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: xc_having_tab1.val2
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 8)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_having_tab1.val2, (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_having_tab1.val2, sum(xc_having_tab1.val)
- Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
-(8 rows)
+ Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
+(6 rows)
select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
?column?
@@ -308,17 +282,15 @@ select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
(3 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: ((xc_having_tab1.val + xc_having_tab1.val2))
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 5)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_having_tab1.val + xc_having_tab1.val2)), (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_having_tab1.val + xc_having_tab1.val2), sum(xc_having_tab1.val)
- Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
-(8 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1
+(6 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
@@ -328,17 +300,15 @@ select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 ha
(1 row)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_having_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_having_tab1.val)))), xc_having_tab1.val2
Filter: (min((min(xc_having_tab1.val))) < xc_having_tab1.val2)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2, (min(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2, min(xc_having_tab1.val)
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4
+(6 rows)
drop table xc_having_tab1;
drop table xc_having_tab2;
@@ -361,12 +331,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
-- having clause containing aggregate
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75;
@@ -381,12 +349,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 or val2 > 2;
count | sum | avg | ?column? | val2
@@ -401,12 +367,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: ((pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75) OR (xc_having_tab1.val2 > 2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 and val2 > 2;
count | sum | avg | ?column? | val2
@@ -419,12 +383,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
-- joins and group by and having
select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab1.val*xc_having_tab2.val), sum(xc_having_tab1.val*xc_having_tab2.val)::float8/count(*), xc_having_tab1.val2, xc_having_tab2.val2 from xc_having_tab1 full outer join xc_having_tab2 on xc_having_tab1.val2 = xc_having_tab2.val2 group by xc_having_tab1.val2, xc_having_tab2.val2 having xc_having_tab1.val2 + xc_having_tab2.val2 > 2;
@@ -444,10 +406,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(xc_having_
-> Nested Loop
Output: xc_having_tab1.val, xc_having_tab2.val, xc_having_tab1.val2, xc_having_tab2.val2
Join Filter: ((xc_having_tab1.val2 = xc_having_tab2.val2) AND ((xc_having_tab1.val2 + xc_having_tab2.val2) > 2))
- -> Data Node Scan on xc_having_tab1
+ -> Data Node Scan on xc_having_tab1 "_REMOTE_TABLE_QUERY_"
Output: xc_having_tab1.val, xc_having_tab1.val2
Remote query: SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true
- -> Data Node Scan on xc_having_tab2
+ -> Data Node Scan on xc_having_tab2 "_REMOTE_TABLE_QUERY_"
Output: xc_having_tab2.val, xc_having_tab2.val2
Remote query: SELECT val, val2 FROM ONLY xc_having_tab2 WHERE true
(14 rows)
@@ -460,17 +422,15 @@ select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
(1 row)
explain (verbose true, costs false, nodes false) select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: xc_having_tab1.val2
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 8)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_having_tab1.val2, (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_having_tab1.val2, sum(xc_having_tab1.val)
- Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(8 rows)
+ Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(6 rows)
select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
?column?
@@ -481,17 +441,15 @@ select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
(3 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: ((xc_having_tab1.val + xc_having_tab1.val2))
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 5)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_having_tab1.val + xc_having_tab1.val2)), (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_having_tab1.val + xc_having_tab1.val2), sum(xc_having_tab1.val)
- Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(8 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(6 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
@@ -501,17 +459,15 @@ select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 ha
(1 row)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_having_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_having_tab1.val)))), xc_having_tab1.val2
Filter: (min((min(xc_having_tab1.val))) < xc_having_tab1.val2)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2, (min(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2, min(xc_having_tab1.val)
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
drop table xc_having_tab1;
drop table xc_having_tab2;
@@ -534,12 +490,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4 ORDER BY 4
-(7 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE ((val2 + 1) > 3)) group_1 GROUP BY 4 ORDER BY 4
+(5 rows)
-- having clause containing aggregate
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75;
@@ -554,12 +508,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 or val2 > 2;
count | sum | avg | ?column? | val2
@@ -574,12 +526,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: ((pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75) OR (xc_having_tab1.val2 > 2))
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75 and val2 > 2;
count | sum | avg | ?column? | val2
@@ -592,12 +542,10 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum(xc_having_tab1.val))), pg_catalog.avg((avg(xc_having_tab1.val))), ((pg_catalog.sum((sum(xc_having_tab1.val))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2
Filter: (pg_catalog.avg((avg(xc_having_tab1.val))) > 3.75)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE (val2 > 2)) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
-- joins and group by and having
select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab1.val*xc_having_tab2.val), sum(xc_having_tab1.val*xc_having_tab2.val)::float8/count(*), xc_having_tab1.val2, xc_having_tab2.val2 from xc_having_tab1 full outer join xc_having_tab2 on xc_having_tab1.val2 = xc_having_tab2.val2 group by xc_having_tab1.val2, xc_having_tab2.val2 having xc_having_tab1.val2 + xc_having_tab2.val2 > 2;
@@ -607,16 +555,14 @@ select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab
(1 row)
explain (verbose true, costs false, nodes false) select count(*), sum(xc_having_tab1.val * xc_having_tab2.val), avg(xc_having_tab1.val*xc_having_tab2.val), sum(xc_having_tab1.val*xc_having_tab2.val)::float8/count(*), xc_having_tab1.val2, xc_having_tab2.val2 from xc_having_tab1 full outer join xc_having_tab2 on xc_having_tab1.val2 = xc_having_tab2.val2 group by xc_having_tab1.val2, xc_having_tab2.val2 having xc_having_tab1.val2 + xc_having_tab2.val2 > 2;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: pg_catalog.count(*), pg_catalog.sum((sum((xc_having_tab1.val * xc_having_tab2.val)))), pg_catalog.avg((avg((xc_having_tab1.val * xc_having_tab2.val)))), ((pg_catalog.sum((sum((xc_having_tab1.val * xc_having_tab2.val)))))::double precision / (pg_catalog.count(*))::double precision), xc_having_tab1.val2, xc_having_tab2.val2
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum((xc_having_tab1.val * xc_having_tab2.val))), (avg((xc_having_tab1.val * xc_having_tab2.val))), xc_having_tab1.val2, xc_having_tab2.val2
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum((xc_having_tab1.val * xc_having_tab2.val)), avg((xc_having_tab1.val * xc_having_tab2.val)), xc_having_tab1.val2, xc_having_tab2.val2
- Remote query: SELECT count(*), sum((group_2.val_1_1_1 * group_2.val_2_1_1)), avg((group_2.val_1_1_1 * group_2.val_2_1_1)), group_2.val2_1_2_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, in_1.val2 AS val2_1_2_1, out_1.val AS val_2_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) in_1 , (SELECT val, val2 FROM ONLY xc_having_tab2 WHERE true) out_1 WHERE ((in_1.val2 = out_1.val2) AND ((in_1.val2 + out_1.val2) > 2))) group_2 GROUP BY 4, 5 ORDER BY 4, 5
-(7 rows)
+ Remote query: SELECT count(*), sum((group_2.val_1_1_1 * group_2.val_2_1_1)), avg((group_2.val_1_1_1 * group_2.val_2_1_1)), group_2.val2_1_2_1, group_2.val2_2_2_1 FROM (SELECT in_1.val AS val_1_1_1, in_1.val2 AS val2_1_2_1, out_1.val AS val_2_1_1, out_1.val2 AS val2_2_2_1 FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) in_1 , (SELECT val, val2 FROM ONLY xc_having_tab2 WHERE true) out_1 WHERE ((in_1.val2 = out_1.val2) AND ((in_1.val2 + out_1.val2) > 2))) group_2 GROUP BY 4, 5 ORDER BY 4, 5
+(5 rows)
-- group by and having, without aggregate in the target list
select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
@@ -626,17 +572,15 @@ select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
(1 row)
explain (verbose true, costs false, nodes false) select val2 from xc_having_tab1 group by val2 having sum(val) > 8;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: xc_having_tab1.val2
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 8)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: xc_having_tab1.val2, (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: xc_having_tab1.val2, sum(xc_having_tab1.val)
- Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(8 rows)
+ Remote query: SELECT group_1.val2, sum(group_1.val) FROM (SELECT val2, val FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(6 rows)
select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
?column?
@@ -647,17 +591,15 @@ select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
(3 rows)
explain (verbose true, costs false, nodes false) select val + val2 from xc_having_tab1 group by val + val2 having sum(val) > 5;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: ((xc_having_tab1.val + xc_having_tab1.val2))
Filter: (pg_catalog.sum((sum(xc_having_tab1.val))) > 5)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: ((xc_having_tab1.val + xc_having_tab1.val2)), (sum(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: (xc_having_tab1.val + xc_having_tab1.val2), sum(xc_having_tab1.val)
- Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
-(8 rows)
+ Remote query: SELECT (group_1.val + group_1.val2), sum(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 1 ORDER BY 1
+(6 rows)
-- group by with aggregates in expression
select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
@@ -667,17 +609,15 @@ select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 ha
(1 row)
explain (verbose true, costs false, nodes false) select count(*) + sum(val) + avg(val), val2 from xc_having_tab1 group by val2 having min(val) < val2;
- QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: (((pg_catalog.count(*) + pg_catalog.sum((sum(xc_having_tab1.val)))))::numeric + pg_catalog.avg((avg(xc_having_tab1.val)))), xc_having_tab1.val2
Filter: (min((min(xc_having_tab1.val))) < xc_having_tab1.val2)
- -> Materialize
+ -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: (count(*)), (sum(xc_having_tab1.val)), (avg(xc_having_tab1.val)), xc_having_tab1.val2, (min(xc_having_tab1.val))
- -> Data Node Scan on "__REMOTE_GROUP_QUERY__"
- Output: count(*), sum(xc_having_tab1.val), avg(xc_having_tab1.val), xc_having_tab1.val2, min(xc_having_tab1.val)
- Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
-(8 rows)
+ Remote query: SELECT count(*), sum(group_1.val), avg(group_1.val), group_1.val2, min(group_1.val) FROM (SELECT val, val2 FROM ONLY xc_having_tab1 WHERE true) group_1 GROUP BY 4 ORDER BY 4
+(6 rows)
drop table xc_having_tab1;
drop table xc_having_tab2;
diff --git a/src/test/regress/expected/xc_remote.out b/src/test/regress/expected/xc_remote.out
index 52ba61d92d..9f8d3211c2 100644
--- a/src/test/regress/expected/xc_remote.out
+++ b/src/test/regress/expected/xc_remote.out
@@ -385,20 +385,18 @@ $$begin return 3;end $$ language plpgsql;
Update on public.xcrem_employee e
Node expr: e.empno
Remote query: UPDATE ONLY public.xcrem_employee SET salary = $12 WHERE ctid = $17 AND xc_node_id = $18
- -> Result
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
Output: e.empno, e.firstname, e.midinit, e.lastname, e.workdept, e.phoneno, e.hiredate, e.job, e.edlevel, e.sex, e.birthdate, ((e.salary + e.salary) + (0.3 * e.bonus)), e.bonus, e.comm, e.salary, e.workdept, e.ctid, e.xc_node_id
- -> Data Node Scan on e
- Output: e.empno, e.firstname, e.midinit, e.lastname, e.workdept, e.phoneno, e.hiredate, e.job, e.edlevel, e.sex, e.birthdate, e.salary, e.bonus, e.comm, e.ctid, e.xc_node_id
- Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: (e.salary > (SubPlan 1))
- SubPlan 1
- -> Aggregate
- Output: avg(xcrem_employee.salary)
- -> Data Node Scan on xcrem_employee
- Output: xcrem_employee.salary, xcrem_employee.workdept
- Remote query: SELECT salary, workdept FROM ONLY xcrem_employee WHERE true
- Coordinator quals: ("substring"((e.workdept)::text, 1, 1) = "substring"((xcrem_employee.workdept)::text, 1, 1))
-(16 rows)
+ Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: (e.salary > (SubPlan 1))
+ SubPlan 1
+ -> Aggregate
+ Output: avg(xcrem_employee.salary)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: xcrem_employee.salary, xcrem_employee.workdept
+ Remote query: SELECT salary, workdept FROM ONLY xcrem_employee WHERE true
+ Coordinator quals: ("substring"((e.workdept)::text, 1, 1) = "substring"((xcrem_employee.workdept)::text, 1, 1))
+(14 rows)
:SEL;
empno | edlevel | lastname | salary | bonus
@@ -429,20 +427,18 @@ $$begin return 3;end $$ language plpgsql;
Update on public.xcrem_employee e
Node expr: e.empno
Remote query: UPDATE ONLY public.xcrem_employee SET bonus = $13 WHERE ctid = $17 AND xc_node_id = $18
- -> Result
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
Output: e.empno, e.firstname, e.midinit, e.lastname, e.workdept, e.phoneno, e.hiredate, e.job, e.edlevel, e.sex, e.birthdate, e.salary, (e.bonus + (e.salary * 0.3)), e.comm, e.edlevel, e.workdept, e.ctid, e.xc_node_id
- -> Data Node Scan on e
- Output: e.empno, e.firstname, e.midinit, e.lastname, e.workdept, e.phoneno, e.hiredate, e.job, e.edlevel, e.sex, e.birthdate, e.salary, e.bonus, e.comm, e.ctid, e.xc_node_id
- Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: ((e.edlevel)::numeric > (SubPlan 1))
- SubPlan 1
- -> Aggregate
- Output: avg(xcrem_employee.edlevel)
- -> Data Node Scan on xcrem_employee
- Output: xcrem_employee.edlevel, xcrem_employee.workdept
- Remote query: SELECT edlevel, workdept FROM ONLY xcrem_employee WHERE true
- Coordinator quals: (xcrem_employee.workdept = e.workdept)
-(16 rows)
+ Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: ((e.edlevel)::numeric > (SubPlan 1))
+ SubPlan 1
+ -> Aggregate
+ Output: avg(xcrem_employee.edlevel)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: xcrem_employee.edlevel, xcrem_employee.workdept
+ Remote query: SELECT edlevel, workdept FROM ONLY xcrem_employee WHERE true
+ Coordinator quals: (xcrem_employee.workdept = e.workdept)
+(14 rows)
:SEL;
empno | edlevel | lastname | salary | bonus
@@ -468,18 +464,16 @@ $$begin return 3;end $$ language plpgsql;
\set stmt 'update xcrem_employee E set lastname = lastname || ''suf'' WHERE EDLEVEL > volatile_func(2)'
:stmt;
:EXP :stmt;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Update on public.xcrem_employee e
Node expr: e.empno
Remote query: UPDATE ONLY public.xcrem_employee SET lastname = $4 WHERE ctid = $16 AND xc_node_id = $17
- -> Result
- Output: empno, firstname, midinit, ((lastname)::text || 'suf'::text), workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, edlevel, ctid, xc_node_id
- -> Data Node Scan on e
- Output: empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id
- Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: (e.edlevel > volatile_func(2))
-(9 rows)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: e.empno, e.firstname, e.midinit, ((e.lastname)::text || 'suf'::text), e.workdept, e.phoneno, e.hiredate, e.job, e.edlevel, e.sex, e.birthdate, e.salary, e.bonus, e.comm, e.edlevel, e.ctid, e.xc_node_id
+ Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: (e.edlevel > volatile_func(2))
+(7 rows)
:SEL;
empno | edlevel | lastname | salary | bonus
@@ -505,18 +499,16 @@ $$begin return 3;end $$ language plpgsql;
\set stmt 'update xcrem_employee E set lastname = lastname || ''suf'', edlevel = edlevel+1 WHERE EDLEVEL > volatile_func(2)'
:stmt;
:EXP :stmt;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Update on public.xcrem_employee e
Node expr: e.empno
Remote query: UPDATE ONLY public.xcrem_employee SET lastname = $4, edlevel = $9 WHERE ctid = $16 AND xc_node_id = $17
- -> Result
- Output: empno, firstname, midinit, ((lastname)::text || 'suf'::text), workdept, phoneno, hiredate, job, (edlevel + 1), sex, birthdate, salary, bonus, comm, edlevel, ctid, xc_node_id
- -> Data Node Scan on e
- Output: empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id
- Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: (e.edlevel > volatile_func(2))
-(9 rows)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: e.empno, e.firstname, e.midinit, ((e.lastname)::text || 'suf'::text), e.workdept, e.phoneno, e.hiredate, e.job, (e.edlevel + 1), e.sex, e.birthdate, e.salary, e.bonus, e.comm, e.edlevel, e.ctid, e.xc_node_id
+ Remote query: SELECT empno, firstname, midinit, lastname, workdept, phoneno, hiredate, job, edlevel, sex, birthdate, salary, bonus, comm, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: (e.edlevel > volatile_func(2))
+(7 rows)
:SEL;
empno | edlevel | lastname | salary | bonus
@@ -546,17 +538,15 @@ insert into xcrem_employee select * from xcrem_temptable;
\set stmt 'DELETE FROM xcrem_employee E WHERE EDLEVEL > volatile_func(2)'
:stmt;
:EXP :stmt;
- QUERY PLAN
-----------------------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
Delete on public.xcrem_employee e
Remote query: DELETE FROM ONLY public.xcrem_employee WHERE ctid = $2 AND xc_node_id = $3
- -> Result
- Output: edlevel, ctid, xc_node_id
- -> Data Node Scan on e
- Output: edlevel, ctid, xc_node_id
- Remote query: SELECT edlevel, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: (e.edlevel > volatile_func(2))
-(8 rows)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: e.edlevel, e.ctid, e.xc_node_id
+ Remote query: SELECT edlevel, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: (e.edlevel > volatile_func(2))
+(6 rows)
:SEL;
empno | edlevel | lastname | salary | bonus
@@ -568,24 +558,22 @@ insert into xcrem_employee select * from xcrem_temptable;
\set stmt 'DELETE FROM xcrem_employee E WHERE EDLEVEL > ( SELECT AVG(EDLEVEL) FROM xcrem_employee WHERE WORKDEPT = E.WORKDEPT )'
:stmt;
:EXP :stmt;
- QUERY PLAN
---------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------
Delete on public.xcrem_employee e
Remote query: DELETE FROM ONLY public.xcrem_employee WHERE ctid = $3 AND xc_node_id = $4
- -> Result
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
Output: e.edlevel, e.workdept, e.ctid, e.xc_node_id
- -> Data Node Scan on e
- Output: e.edlevel, e.workdept, e.ctid, e.xc_node_id
- Remote query: SELECT edlevel, workdept, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: ((e.edlevel)::numeric > (SubPlan 1))
- SubPlan 1
- -> Aggregate
- Output: avg(xcrem_employee.edlevel)
- -> Data Node Scan on xcrem_employee
- Output: xcrem_employee.edlevel, xcrem_employee.workdept
- Remote query: SELECT edlevel, workdept FROM ONLY xcrem_employee WHERE true
- Coordinator quals: (xcrem_employee.workdept = e.workdept)
-(15 rows)
+ Remote query: SELECT edlevel, workdept, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: ((e.edlevel)::numeric > (SubPlan 1))
+ SubPlan 1
+ -> Aggregate
+ Output: avg(xcrem_employee.edlevel)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: xcrem_employee.edlevel, xcrem_employee.workdept
+ Remote query: SELECT edlevel, workdept FROM ONLY xcrem_employee WHERE true
+ Coordinator quals: (xcrem_employee.workdept = e.workdept)
+(13 rows)
:SEL;
empno | edlevel | lastname | salary | bonus
@@ -608,24 +596,22 @@ insert into xcrem_employee select * from xcrem_temptable;
\set stmt 'DELETE FROM xcrem_employee E WHERE SALARY > ( SELECT AVG(SALARY) FROM xcrem_employee WHERE SUBSTRING(E.WORKDEPT,1,1) = SUBSTRING(WORKDEPT, 1,1) )'
:stmt;
:EXP :stmt;
- QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------
Delete on public.xcrem_employee e
Remote query: DELETE FROM ONLY public.xcrem_employee WHERE ctid = $3 AND xc_node_id = $4
- -> Result
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
Output: e.salary, e.workdept, e.ctid, e.xc_node_id
- -> Data Node Scan on e
- Output: e.salary, e.workdept, e.ctid, e.xc_node_id
- Remote query: SELECT salary, workdept, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
- Coordinator quals: (e.salary > (SubPlan 1))
- SubPlan 1
- -> Aggregate
- Output: avg(xcrem_employee.salary)
- -> Data Node Scan on xcrem_employee
- Output: xcrem_employee.salary, xcrem_employee.workdept
- Remote query: SELECT salary, workdept FROM ONLY xcrem_employee WHERE true
- Coordinator quals: ("substring"((e.workdept)::text, 1, 1) = "substring"((xcrem_employee.workdept)::text, 1, 1))
-(15 rows)
+ Remote query: SELECT salary, workdept, ctid, xc_node_id FROM ONLY xcrem_employee e WHERE true
+ Coordinator quals: (e.salary > (SubPlan 1))
+ SubPlan 1
+ -> Aggregate
+ Output: avg(xcrem_employee.salary)
+ -> Data Node Scan on xcrem_employee "_REMOTE_TABLE_QUERY_"
+ Output: xcrem_employee.salary, xcrem_employee.workdept
+ Remote query: SELECT salary, workdept FROM ONLY xcrem_employee WHERE true
+ Coordinator quals: ("substring"((e.workdept)::text, 1, 1) = "substring"((xcrem_employee.workdept)::text, 1, 1))
+(13 rows)
:SEL;
empno | edlevel | lastname | salary | bonus