From: Tomas Vondra Date: Fri, 14 Jul 2017 23:43:53 +0000 (+0200) Subject: Stabilize result ordering in xc_having regression test X-Git-Tag: XL_10_R1BETA1~217 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=2b87e40619ca0ad94741ca2d511720fdac44e0f9;p=postgres-xl.git Stabilize result ordering in xc_having regression test Stabilized by adding ORDER BY clause to two queries. Generate explain plans both for the original and modified queries. --- diff --git a/src/test/regress/expected/xc_having.out b/src/test/regress/expected/xc_having.out index 1de1cf4b6a..9fea4093ed 100644 --- a/src/test/regress/expected/xc_having.out +++ b/src/test/regress/expected/xc_having.out @@ -59,13 +59,32 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg( Output: val, val2 (11 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; +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 order by 1; count | sum | avg | ?column? | val2 -------+-----+--------------------+------------------+------ - 3 | 11 | 3.6666666666666667 | 3.66666666666667 | 3 2 | 8 | 4.0000000000000000 | 4 | 2 + 3 | 11 | 3.6666666666666667 | 3.66666666666667 | 3 (2 rows) +explain (verbose true, costs false, nodes false) 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 order by 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- + Sort + Output: (count(*)), (sum(val)), (avg(val)), (((sum(val))::double precision / (count(*))::double precision)), val2 + Sort Key: (count(*)) + -> Finalize HashAggregate + Output: count(*), sum(val), avg(val), ((sum(val))::double precision / (count(*))::double precision), val2 + Group Key: xc_having_tab1.val2 + Filter: ((avg(xc_having_tab1.val) > 3.75) OR (xc_having_tab1.val2 > 2)) + -> Remote Subquery Scan on all + Output: val2, PARTIAL count(*), PARTIAL sum(val), PARTIAL avg(val) + -> Partial HashAggregate + Output: val2, PARTIAL count(*), PARTIAL sum(val), PARTIAL avg(val) + Group Key: xc_having_tab1.val2 + -> Seq Scan on public.xc_having_tab1 + Output: val, val2 +(14 rows) + explain (verbose true, costs false, nodes false) 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; QUERY PLAN ------------------------------------------------------------------------------------------------------------- @@ -269,13 +288,29 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg( Output: val, val2 (8 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; +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 order by 1; count | sum | avg | ?column? | val2 -------+-----+--------------------+------------------+------ - 3 | 11 | 3.6666666666666667 | 3.66666666666667 | 3 2 | 8 | 4.0000000000000000 | 4 | 2 + 3 | 11 | 3.6666666666666667 | 3.66666666666667 | 3 (2 rows) +explain (verbose true, costs false, nodes false) 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 order by 1; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Remote Subquery Scan on all + Output: count(*), sum(val), avg(val), ((sum(val))::double precision / (count(*))::double precision), val2 + -> Sort + Output: (count(*)), (sum(val)), (avg(val)), (((sum(val))::double precision / (count(*))::double precision)), val2 + Sort Key: (count(*)) + -> HashAggregate + Output: count(*), sum(val), avg(val), ((sum(val))::double precision / (count(*))::double precision), val2 + Group Key: xc_having_tab1.val2 + Filter: ((avg(xc_having_tab1.val) > 3.75) OR (xc_having_tab1.val2 > 2)) + -> Seq Scan on public.xc_having_tab1 + Output: val, val2 +(11 rows) + explain (verbose true, costs false, nodes false) 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; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- diff --git a/src/test/regress/sql/xc_having.sql b/src/test/regress/sql/xc_having.sql index 061ca3ae1c..4f11110115 100644 --- a/src/test/regress/sql/xc_having.sql +++ b/src/test/regress/sql/xc_having.sql @@ -21,7 +21,8 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg( -- 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; explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75; -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; +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 order by 1; +explain (verbose true, costs false, nodes false) 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 order by 1; explain (verbose true, costs false, nodes false) 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; 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; explain (verbose true, costs false, nodes false) 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; @@ -52,7 +53,8 @@ explain (verbose true, costs false, nodes false) select count(*), sum(val), avg( -- 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; explain (verbose true, costs false, nodes false) select count(*), sum(val), avg(val), sum(val)::float8/count(*), val2 from xc_having_tab1 group by val2 having avg(val) > 3.75; -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; +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 order by 1; +explain (verbose true, costs false, nodes false) 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 order by 1; explain (verbose true, costs false, nodes false) 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; 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; explain (verbose true, costs false, nodes false) 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;