Skip to content

Commit

Permalink
Oler Blasco (<notifications@github.com>)'s fix for FQS.
Browse files Browse the repository at this point in the history
Thanks a lot for the contribution!

	modified:   src/backend/optimizer/util/pgxcship.c
	modified:   src/test/regress/expected/xc_FQS.out
  • Loading branch information
koichi-szk committed Jun 3, 2016
1 parent 1e1b877 commit e6df5f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/backend/optimizer/util/pgxcship.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,12 @@ pgxc_shippability_walker(Node *node, Shippability_context *sc_context)
!pgxc_query_has_distcolgrouping(query, sc_context->sc_exec_nodes))
pgxc_set_shippability_reason(sc_context, SS_NEED_SINGLENODE);

/* Grouping by non distribution column can not be FQS*/
if (query->groupClause != NULL &&
sc_context->sc_exec_nodes &&
!pgxc_query_has_distcolgrouping(query, sc_context->sc_exec_nodes))
pgxc_set_shippability_reason(sc_context, SS_NEED_SINGLENODE);

/*
* If distribution column of any relation is present in the distinct
* clause, values for that column across nodes will differ, thus two
Expand Down
12 changes: 7 additions & 5 deletions src/test/regress/expected/xc_FQS.out
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,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
------------------------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__"
QUERY PLAN
------------------------------------------------------------------------------------------------
HashAggregate
Output: tab1_rr.val, tab1_rr.val2
Remote query: SELECT val, val2 FROM public.tab1_rr WHERE (val2 = 8) GROUP BY val, val2
(3 rows)
-> Data Node Scan on "__REMOTE_GROUP_QUERY__"
Output: tab1_rr.val, tab1_rr.val2
Remote query: SELECT val, val2 FROM ONLY public.tab1_rr WHERE (val2 = 8) GROUP BY 1, 2
(5 rows)

-- should not get FQSed because of presence of aggregates and HAVING clause,
select sum(val) from tab1_rr where val2 = 2 group by val2 having sum(val) > 1;
Expand Down

0 comments on commit e6df5f1

Please sign in to comment.