From 633aa5686c36b03c51f4bf1e2a804f984451ac1c Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Tue, 27 Nov 2018 13:03:50 +0300 Subject: [PATCH] Pushdown only necessary projections in the recursive relation planning With this commit, we only pull&push the necessary columns. In this context, necessary columns means that the columns that are required for the query to be executed when the relation is wrapped into a subquery. We could potentially optimize things further: (a) If a column only appears as a qual filter, we don't need to pull it to the coordinator (b) We currently pull unnecessary columns as NULL. However, we could potentially adjust remaining of the query tree and do not add columns of the relation to the target entry. --- .../planner/query_colocation_checker.c | 36 ++++++++--- .../distributed/planner/recursive_planning.c | 60 ++++++++++++++++++- .../distributed/query_colocation_checker.h | 3 +- .../expected/non_colocated_subquery_joins.out | 2 +- ...relation_planning_restriction_pushdown.out | 58 +++++++++--------- 5 files changed, 118 insertions(+), 41 deletions(-) diff --git a/src/backend/distributed/planner/query_colocation_checker.c b/src/backend/distributed/planner/query_colocation_checker.c index 5340bd9b2..b5482a017 100644 --- a/src/backend/distributed/planner/query_colocation_checker.c +++ b/src/backend/distributed/planner/query_colocation_checker.c @@ -71,7 +71,7 @@ CreateColocatedJoinChecker(Query *subquery, PlannerRestrictionContext *restricti * functions (i.e., FilterPlannerRestrictionForQuery()) rely on queries * not relations. */ - anchorSubquery = WrapRteRelationIntoSubquery(anchorRangeTblEntry); + anchorSubquery = WrapRteRelationIntoSubquery(anchorRangeTblEntry, NIL); } else if (anchorRangeTblEntry->rtekind == RTE_SUBQUERY) { @@ -237,9 +237,19 @@ SubqueryColocated(Query *subquery, ColocatedJoinChecker *checker) * Note that the query returned by this function does not contain any filters or * projections. The returned query should be used cautiosly and it is mostly * designed for generating a stub query. + * + * The function also gets requiredAttrNumbersForRelation. The attributes that are + * not inside the list are added as NULL to the target list. We prefer to do this + * over not including the entries at all in the target list. The reason is that + * if any other part of the query refers to a varatto of the relation, we should + * continue to serve the target entry from the same position in the target list of + * the subquery. + * + * If the requiredAttrNumbersForRelation is NIL, all entries are added as NULL. */ Query * -WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation) +WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation, + List *requiredAttrNumbersForRelation) { Query *subquery = makeNode(Query); RangeTblRef *newRangeTableRef = makeNode(RangeTblRef); @@ -266,14 +276,26 @@ WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation) for (attributeNumber = 1; attributeNumber <= numberOfAttributes; attributeNumber++) { - Form_pg_attribute attributeTuple = TupleDescAttr(relation->rd_att, - attributeNumber - 1); + Form_pg_attribute attributeTuple = + TupleDescAttr(relation->rd_att, attributeNumber - 1); Var *targetColumn = makeVar(1, attributeNumber, attributeTuple->atttypid, attributeTuple->atttypmod, attributeTuple->attcollation, 0); - TargetEntry *targetEntry = - makeTargetEntry((Expr *) targetColumn, attributeNumber, - strdup(attributeTuple->attname.data), false); + TargetEntry *targetEntry = targetEntry = + makeTargetEntry((Expr *) targetColumn, + attributeNumber, + strdup( + attributeTuple->attname.data), + false); + + if (!(requiredAttrNumbersForRelation && + list_member_int(requiredAttrNumbersForRelation, attributeNumber))) + { + targetEntry->expr = + (Expr *) makeNullConst(attributeTuple->atttypid, + attributeTuple->atttypmod, + attributeTuple->attcollation); + } subquery->targetList = lappend(subquery->targetList, targetEntry); } diff --git a/src/backend/distributed/planner/recursive_planning.c b/src/backend/distributed/planner/recursive_planning.c index 5a554c897..8602b2f18 100644 --- a/src/backend/distributed/planner/recursive_planning.c +++ b/src/backend/distributed/planner/recursive_planning.c @@ -77,6 +77,7 @@ #include "nodes/primnodes.h" #include "nodes/relation.h" #include "optimizer/clauses.h" +#include "optimizer/var.h" #include "utils/builtins.h" #include "utils/guc.h" #include "utils/lsyscache.h" @@ -158,6 +159,8 @@ static void RecursivelyPlanSetOperations(Query *query, Node *node, static bool IsLocalTableRTE(Node *node); static void RecursivelyPlanRTERelation(RangeTblEntry *relationRte, RecursivePlanningContext *planningContext); +static List * RequiredAttrNumbersForRelation(RangeTblEntry *relationRte, + RecursivePlanningContext *planningContext); static void RecursivelyPlanSubquery(Query *subquery, RecursivePlanningContext *planningContext); static DistributedSubPlan * CreateDistributedSubPlan(uint32 subPlanId, @@ -478,7 +481,7 @@ RecursivelyPlanNonColocatedJoinWalker(Node *joinNode, if (rte->rtekind == RTE_RELATION) { - subquery = WrapRteRelationIntoSubquery(rte); + subquery = WrapRteRelationIntoSubquery(rte, NIL); if (!SubqueryColocated(subquery, colocatedJoinChecker)) { @@ -1105,15 +1108,18 @@ RecursivelyPlanRTERelation(RangeTblEntry *relationRte, planningContext->plannerRestrictionContext; List *restrictionExprListOnTable = GetRestrictInfoListForRelation(relationRte, plannerRestrictionContext); + List *requiredAttrNumbersForRelation = + RequiredAttrNumbersForRelation(relationRte, planningContext); - Query *subquery = WrapRteRelationIntoSubquery(relationRte); + Query *subquery = + WrapRteRelationIntoSubquery(relationRte, requiredAttrNumbersForRelation); RangeTblEntry *wrappedSubqueryEntry = makeNode(RangeTblEntry); ListCell *columnListCell = NULL; List *columnNames = NIL; char *relationName = get_rel_name(relationRte->relid); wrappedSubqueryEntry->rtekind = RTE_SUBQUERY; - wrappedSubqueryEntry->subquery = copyObject(subquery); + wrappedSubqueryEntry->subquery = subquery; foreach(columnListCell, subquery->targetList) { @@ -1140,6 +1146,54 @@ RecursivelyPlanRTERelation(RangeTblEntry *relationRte, } +/* + * RequiredAttrNumbersForRelation returns the required attribute numbers for + * the input RTE relation in order for the planning to succeed. + * + * The function could be optimized by not adding the columns that only appear + * WHERE clause as a filter (e.g., not a join clause). + */ +static List * +RequiredAttrNumbersForRelation(RangeTblEntry *relationRte, + RecursivePlanningContext *planningContext) +{ + PlannerRestrictionContext *plannerRestrictionContext = + planningContext->plannerRestrictionContext; + PlannerRestrictionContext *filteredPlannerRestrictionContext = + FilterPlannerRestrictionForQuery(plannerRestrictionContext, + WrapRteRelationIntoSubquery(relationRte, NIL)); + + RelationRestrictionContext *relationRestrictionContext = + filteredPlannerRestrictionContext->relationRestrictionContext; + List *filteredRelationRestrictionList = + relationRestrictionContext->relationRestrictionList; + RelationRestriction *relationRestriction = + (RelationRestriction *) linitial(filteredRelationRestrictionList); + + PlannerInfo *plannerInfo = relationRestriction->plannerInfo; + Query *queryToProcess = plannerInfo->parse; + int rteIndex = relationRestriction->index; + + List *allVarsInQuery = pull_vars_of_level((Node *) queryToProcess, 0); + ListCell *varCell = NULL; + + List *requiredAttrNumbers = NIL; + + foreach(varCell, allVarsInQuery) + { + Var *var = (Var *) lfirst(varCell); + + if (var->varno == rteIndex) + { + requiredAttrNumbers = list_append_unique_int(requiredAttrNumbers, + var->varattno); + } + } + + return requiredAttrNumbers; +} + + /* * RecursivelyPlanQuery recursively plans a query, replaces it with a * result query and returns the subplan. diff --git a/src/include/distributed/query_colocation_checker.h b/src/include/distributed/query_colocation_checker.h index 79913fc2c..78feb42fe 100644 --- a/src/include/distributed/query_colocation_checker.h +++ b/src/include/distributed/query_colocation_checker.h @@ -34,7 +34,8 @@ extern ColocatedJoinChecker CreateColocatedJoinChecker(Query *subquery, PlannerRestrictionContext * restrictionContext); extern bool SubqueryColocated(Query *subquery, ColocatedJoinChecker *context); -extern Query * WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation); +extern Query * WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation, + List *requiredAttrNumbersForRelation); #endif /* QUERY_COLOCATION_CHECKER_H */ diff --git a/src/test/regress/expected/non_colocated_subquery_joins.out b/src/test/regress/expected/non_colocated_subquery_joins.out index bb79c884a..ae84a10cd 100644 --- a/src/test/regress/expected/non_colocated_subquery_joins.out +++ b/src/test/regress/expected/non_colocated_subquery_joins.out @@ -642,7 +642,7 @@ SELECT true AS valid FROM explain_json_2($$ FROM (users_table u1 JOIN users_table u2 using(value_1)) a JOIN (SELECT value_1, random() FROM users_table) as u3 USING (value_1); $$); -DEBUG: generating subplan 66_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 66_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 66_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 66 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('66_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) a(value_1, user_id, "time", value_2, value_3, value_4, user_id_1, time_1, value_2_1, value_3_1, value_4_1) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('66_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) valid diff --git a/src/test/regress/expected/recursive_relation_planning_restriction_pushdown.out b/src/test/regress/expected/recursive_relation_planning_restriction_pushdown.out index 18c6f26a3..6c5c49f4c 100644 --- a/src/test/regress/expected/recursive_relation_planning_restriction_pushdown.out +++ b/src/test/regress/expected/recursive_relation_planning_restriction_pushdown.out @@ -20,7 +20,7 @@ JOIN (SELECT value_1, random() FROM users_table) AS u3 USING (value_1); -DEBUG: generating subplan 1_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 1_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 1_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 1 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('1_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('1_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) count @@ -37,7 +37,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u2.value_1 > ANY(ARRAY[2, 1, 6]); -DEBUG: generating subplan 4_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (value_1 OPERATOR(pg_catalog.>) ANY ('{2,1,6}'::integer[])) +DEBUG: generating subplan 4_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (value_1 OPERATOR(pg_catalog.>) ANY ('{2,1,6}'::integer[])) DEBUG: generating subplan 4_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 4 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('4_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('4_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (users_table.value_1 OPERATOR(pg_catalog.>) ANY (ARRAY[2, 1, 6])) count @@ -54,7 +54,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE ARRAY[u2.value_1, u2.value_2] @> (ARRAY[2, 3]); -DEBUG: generating subplan 7_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (ARRAY[value_1, value_2] OPERATOR(pg_catalog.@>) '{2,3}'::integer[]) +DEBUG: generating subplan 7_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (ARRAY[value_1, value_2] OPERATOR(pg_catalog.@>) '{2,3}'::integer[]) DEBUG: generating subplan 7_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 7 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('7_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('7_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (ARRAY[users_table.value_1, users_table.value_2] OPERATOR(pg_catalog.@>) ARRAY[2, 3]) count @@ -71,7 +71,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE ARRAY[u2.value_1, u1.user_id] @> (ARRAY[2, 3]); -DEBUG: generating subplan 10_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 10_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 10_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 10 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('10_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('10_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (ARRAY[users_table.value_1, u1.user_id] OPERATOR(pg_catalog.@>) ARRAY[2, 3]) count @@ -88,7 +88,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1/2.0 > 2)::int::bool::text::bool; -DEBUG: generating subplan 13_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (((((((value_1)::numeric OPERATOR(pg_catalog./) 2.0) OPERATOR(pg_catalog.>) '2'::numeric))::integer)::boolean)::text)::boolean +DEBUG: generating subplan 13_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (((((((value_1)::numeric OPERATOR(pg_catalog./) 2.0) OPERATOR(pg_catalog.>) '2'::numeric))::integer)::boolean)::text)::boolean DEBUG: generating subplan 13_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 13 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('13_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('13_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (((((((users_table.value_1)::numeric OPERATOR(pg_catalog./) 2.0) OPERATOR(pg_catalog.>) (2)::numeric))::integer)::boolean)::text)::boolean count @@ -105,7 +105,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (CASE WHEN u2.value_1 > 3 THEN u2.value_1 > 2 ELSE false END); -DEBUG: generating subplan 16_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE CASE WHEN (value_1 OPERATOR(pg_catalog.>) 3) THEN (value_1 OPERATOR(pg_catalog.>) 2) ELSE false END +DEBUG: generating subplan 16_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE CASE WHEN (value_1 OPERATOR(pg_catalog.>) 3) THEN (value_1 OPERATOR(pg_catalog.>) 2) ELSE false END DEBUG: generating subplan 16_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 16 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('16_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('16_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE CASE WHEN (users_table.value_1 OPERATOR(pg_catalog.>) 3) THEN (users_table.value_1 OPERATOR(pg_catalog.>) 2) ELSE false END count @@ -122,7 +122,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (CASE WHEN u1.value_1 > 4000 THEN u2.value_1 / 100 > 1 ELSE false END); -DEBUG: generating subplan 19_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 19_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 19_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 19 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('19_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('19_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE CASE WHEN (u1.value_1 OPERATOR(pg_catalog.>) 4000) THEN ((users_table.value_1 OPERATOR(pg_catalog./) 100) OPERATOR(pg_catalog.>) 1) ELSE false END count @@ -139,7 +139,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE COALESCE((u2.user_id/5.0)::int::bool, false); -DEBUG: generating subplan 22_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE COALESCE(((((user_id)::numeric OPERATOR(pg_catalog./) 5.0))::integer)::boolean, false) +DEBUG: generating subplan 22_1 for subquery SELECT user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE COALESCE(((((user_id)::numeric OPERATOR(pg_catalog./) 5.0))::integer)::boolean, false) DEBUG: generating subplan 22_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 22 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('22_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE COALESCE(((((users_table.user_id)::numeric OPERATOR(pg_catalog./) 5.0))::integer)::boolean, false) count @@ -156,7 +156,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE NULLIF((u2.value_2/5.0)::int::bool, false); -DEBUG: generating subplan 25_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE NULLIF(((((value_2)::numeric OPERATOR(pg_catalog./) 5.0))::integer)::boolean, false) +DEBUG: generating subplan 25_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE NULLIF(((((value_2)::numeric OPERATOR(pg_catalog./) 5.0))::integer)::boolean, false) DEBUG: generating subplan 25_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 25 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('25_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('25_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE NULLIF(((((users_table.value_2)::numeric OPERATOR(pg_catalog./) 5.0))::integer)::boolean, false) count @@ -173,7 +173,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u2.value_3 IS NOT NULL; -DEBUG: generating subplan 28_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (value_3 IS NOT NULL) +DEBUG: generating subplan 28_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (value_3 IS NOT NULL) DEBUG: generating subplan 28_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 28 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('28_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('28_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (users_table.value_3 IS NOT NULL) count @@ -190,7 +190,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE isfinite(u2.time); -DEBUG: generating subplan 31_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE isfinite("time") +DEBUG: generating subplan 31_1 for subquery SELECT NULL::integer AS user_id, "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE isfinite("time") DEBUG: generating subplan 31_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 31 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('31_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('31_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE isfinite(users_table."time") count @@ -207,7 +207,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE int4smaller(u2.value_1, u1.value_1) = 55; -DEBUG: generating subplan 34_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 34_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 34_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 34 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('34_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('34_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (int4smaller(users_table.value_1, u1.value_1) OPERATOR(pg_catalog.=) 55) count @@ -224,7 +224,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE int4smaller(u2.value_1, u2.value_2) = u2.value_1; -DEBUG: generating subplan 37_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (value_1 OPERATOR(pg_catalog.=) int4smaller(value_1, value_2)) +DEBUG: generating subplan 37_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (value_1 OPERATOR(pg_catalog.=) int4smaller(value_1, value_2)) DEBUG: generating subplan 37_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 37 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('37_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('37_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (int4smaller(users_table.value_1, users_table.value_2) OPERATOR(pg_catalog.=) users_table.value_1) count @@ -241,7 +241,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE row(u2.value_1, 2, 3) > row(u2.value_2, 2, 3); -DEBUG: generating subplan 40_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (ROW(value_1, 2, 3) OPERATOR(pg_catalog.>) ROW(value_2, 2, 3)) +DEBUG: generating subplan 40_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (ROW(value_1, 2, 3) OPERATOR(pg_catalog.>) ROW(value_2, 2, 3)) DEBUG: generating subplan 40_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 40 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('40_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('40_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (ROW(users_table.value_1, 2, 3) OPERATOR(pg_catalog.>) ROW(users_table.value_2, 2, 3)) count @@ -285,7 +285,7 @@ WHERE u2.value_1 > (SELECT avg(user_id) FROM events_table); DEBUG: generating subplan 46_1 for subquery SELECT avg(user_id) AS avg FROM public.events_table -DEBUG: generating subplan 46_2 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 46_2 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 46_3 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 46 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('46_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('46_3'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE ((users_table.value_1)::numeric OPERATOR(pg_catalog.>) (SELECT intermediate_result.avg FROM read_intermediate_result('46_1'::text, 'binary'::citus_copy_format) intermediate_result(avg numeric))) count @@ -303,7 +303,7 @@ JOIN FROM users_table) AS u3 USING (value_1) WHERE u2.value_1 > (SELECT 5); -DEBUG: generating subplan 50_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 50_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 50_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 50 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('50_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('50_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (users_table.value_1 OPERATOR(pg_catalog.>) (SELECT 5)) count @@ -320,7 +320,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u2.value_1 * u1.user_id > 25; -DEBUG: generating subplan 53_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 53_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 53_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 53 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('53_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('53_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE ((users_table.value_1 OPERATOR(pg_catalog.*) u1.user_id) OPERATOR(pg_catalog.>) 25) count @@ -339,7 +339,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u1.value_1 = 3; -DEBUG: generating subplan 56_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (value_1 OPERATOR(pg_catalog.=) 3) +DEBUG: generating subplan 56_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (value_1 OPERATOR(pg_catalog.=) 3) DEBUG: generating subplan 56_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 56 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('56_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('56_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (u1.value_1 OPERATOR(pg_catalog.=) 3) count @@ -356,7 +356,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u1.value_1 > 3; -DEBUG: generating subplan 59_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 59_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 59_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 59 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('59_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('59_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (u1.value_1 OPERATOR(pg_catalog.>) 3) count @@ -374,7 +374,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u1.value_2 = 3; -DEBUG: generating subplan 62_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 62_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 62_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 62 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('62_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('62_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (u1.value_2 OPERATOR(pg_catalog.=) 3) count @@ -391,7 +391,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u2.value_1 > 4 OR u2.value_4 = 4; -DEBUG: generating subplan 65_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 4) OR (value_4 OPERATOR(pg_catalog.=) 4)) +DEBUG: generating subplan 65_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 4) OR (value_4 OPERATOR(pg_catalog.=) 4)) DEBUG: generating subplan 65_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 65 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('65_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('65_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE ((users_table.value_1 OPERATOR(pg_catalog.>) 4) OR (users_table.value_4 OPERATOR(pg_catalog.=) 4)) count @@ -408,7 +408,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE u2.value_1 > 2 and u2.value_4 IS NULL; -DEBUG: generating subplan 68_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 2) AND (value_4 IS NULL)) +DEBUG: generating subplan 68_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 2) AND (value_4 IS NULL)) DEBUG: generating subplan 68_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 68 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('68_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('68_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE ((users_table.value_1 OPERATOR(pg_catalog.>) 2) AND (users_table.value_4 IS NULL)) count @@ -426,7 +426,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1 > 2 OR u2.value_4 IS NULL) AND (u2.user_id > 4 OR u1.user_id > 3); -DEBUG: generating subplan 71_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 2) OR (value_4 IS NULL)) +DEBUG: generating subplan 71_1 for subquery SELECT user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 2) OR (value_4 IS NULL)) DEBUG: generating subplan 71_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 71 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('71_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('71_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (((users_table.value_1 OPERATOR(pg_catalog.>) 2) OR (users_table.value_4 IS NULL)) AND ((users_table.user_id OPERATOR(pg_catalog.>) 4) OR (u1.user_id OPERATOR(pg_catalog.>) 3))) count @@ -443,7 +443,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1 > 2 OR u2.value_4 IS NULL) OR (u2.user_id > 4 AND u1.user_id > 3); -DEBUG: generating subplan 74_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 2) OR (value_4 IS NULL) OR (user_id OPERATOR(pg_catalog.>) 4)) +DEBUG: generating subplan 74_1 for subquery SELECT user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, value_4 FROM public.users_table u2 WHERE ((value_1 OPERATOR(pg_catalog.>) 2) OR (value_4 IS NULL) OR (user_id OPERATOR(pg_catalog.>) 4)) DEBUG: generating subplan 74_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 74 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('74_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('74_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE ((users_table.value_1 OPERATOR(pg_catalog.>) 2) OR (users_table.value_4 IS NULL) OR ((users_table.user_id OPERATOR(pg_catalog.>) 4) AND (u1.user_id OPERATOR(pg_catalog.>) 3))) count @@ -460,7 +460,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1 > 2 OR u1.value_4 IS NULL) AND (u2.user_id > 4 AND u1.user_id > 3); -DEBUG: generating subplan 77_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE (user_id OPERATOR(pg_catalog.>) 4) +DEBUG: generating subplan 77_1 for subquery SELECT user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE (user_id OPERATOR(pg_catalog.>) 4) DEBUG: generating subplan 77_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 77 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('77_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('77_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (((users_table.value_1 OPERATOR(pg_catalog.>) 2) OR (u1.value_4 IS NULL)) AND ((users_table.user_id OPERATOR(pg_catalog.>) 4) AND (u1.user_id OPERATOR(pg_catalog.>) 3))) count @@ -477,7 +477,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1 > 2 OR u1.value_4 IS NULL) AND (u2.user_id > 4 OR u1.user_id > 3); -DEBUG: generating subplan 80_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 80_1 for subquery SELECT user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 80_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 80 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('80_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('80_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (((users_table.value_1 OPERATOR(pg_catalog.>) 2) OR (u1.value_4 IS NULL)) AND ((users_table.user_id OPERATOR(pg_catalog.>) 4) OR (u1.user_id OPERATOR(pg_catalog.>) 3))) count @@ -495,7 +495,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1 > 2 OR u1.value_4 IS NULL) AND (u2.user_id = 10000 * random() OR u1.user_id > 3); -DEBUG: generating subplan 83_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 83_1 for subquery SELECT user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 83_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 83 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('83_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('83_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE (((users_table.value_1 OPERATOR(pg_catalog.>) 2) OR (u1.value_4 IS NULL)) AND (((users_table.user_id)::double precision OPERATOR(pg_catalog.=) ((10000)::double precision OPERATOR(pg_catalog.*) random())) OR (u1.user_id OPERATOR(pg_catalog.>) 3))) count @@ -512,7 +512,7 @@ JOIN random() FROM users_table) AS u3 USING (value_1) WHERE (u2.value_1 > 2 AND false); -DEBUG: generating subplan 86_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 86_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: generating subplan 86_2 for subquery SELECT value_1, random() AS random FROM public.users_table DEBUG: Plan 86 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('86_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN (SELECT intermediate_result.value_1, intermediate_result.random FROM read_intermediate_result('86_2'::text, 'binary'::citus_copy_format) intermediate_result(value_1 integer, random double precision)) u3 USING (value_1)) WHERE ((users_table.value_1 OPERATOR(pg_catalog.>) 2) AND false) count @@ -531,6 +531,6 @@ JOIN LATERAL WHERE u2.value_2 = 15) AS u3 USING (value_1) WHERE (u2.value_1 > 2 AND FALSE); -DEBUG: generating subplan 89_1 for subquery SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.users_table u2 WHERE true +DEBUG: generating subplan 89_1 for subquery SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", value_1, value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 FROM public.users_table u2 WHERE true DEBUG: Plan 89 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((public.users_table u1 JOIN (SELECT intermediate_result.user_id, intermediate_result."time", intermediate_result.value_1, intermediate_result.value_2, intermediate_result.value_3, intermediate_result.value_4 FROM read_intermediate_result('89_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, "time" timestamp without time zone, value_1 integer, value_2 integer, value_3 double precision, value_4 bigint)) users_table(user_id, "time", value_1, value_2, value_3, value_4) USING (value_1)) JOIN LATERAL (SELECT users_table_1.value_1, random() AS random FROM public.users_table users_table_1 WHERE (users_table.value_2 OPERATOR(pg_catalog.=) 15)) u3 USING (value_1)) WHERE ((users_table.value_1 OPERATOR(pg_catalog.>) 2) AND false) ERROR: complex joins are only supported when all distributed tables are joined on their distribution columns with equal operator