|
|
|
|
@ -1644,10 +1644,10 @@ SET work_mem='64kB'; |
|
|
|
|
set enable_hashagg = false; |
|
|
|
|
set jit_above_cost = 0; |
|
|
|
|
explain (costs off) |
|
|
|
|
select g1000, g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
select g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
(select g%1000 as g1000, g%100 as g100, g%10 as g10, g |
|
|
|
|
from generate_series(0,199999) g) s |
|
|
|
|
group by cube (g1000,g100,g10); |
|
|
|
|
from generate_series(0,1999) g) s |
|
|
|
|
group by cube (g1000, g100,g10); |
|
|
|
|
QUERY PLAN |
|
|
|
|
--------------------------------------------------------------- |
|
|
|
|
GroupAggregate |
|
|
|
|
@ -1667,31 +1667,18 @@ group by cube (g1000,g100,g10); |
|
|
|
|
(14 rows) |
|
|
|
|
|
|
|
|
|
create table gs_group_1 as |
|
|
|
|
select g1000, g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
select g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
(select g%1000 as g1000, g%100 as g100, g%10 as g10, g |
|
|
|
|
from generate_series(0,199999) g) s |
|
|
|
|
group by cube (g1000,g100,g10); |
|
|
|
|
set jit_above_cost to default; |
|
|
|
|
create table gs_group_2 as |
|
|
|
|
select g1000, g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
(select g/20 as g1000, g/200 as g100, g/2000 as g10, g |
|
|
|
|
from generate_series(0,19999) g) s |
|
|
|
|
group by cube (g1000,g100,g10); |
|
|
|
|
create table gs_group_3 as |
|
|
|
|
select g100, g10, array_agg(g) as a, count(*) as c, max(g::text) as m from |
|
|
|
|
(select g/200 as g100, g/2000 as g10, g |
|
|
|
|
from generate_series(0,19999) g) s |
|
|
|
|
group by grouping sets (g100,g10); |
|
|
|
|
from generate_series(0,1999) g) s |
|
|
|
|
group by cube (g1000, g100,g10); |
|
|
|
|
-- Produce results with hash aggregation. |
|
|
|
|
set enable_hashagg = true; |
|
|
|
|
set enable_sort = false; |
|
|
|
|
set work_mem='64kB'; |
|
|
|
|
set jit_above_cost = 0; |
|
|
|
|
explain (costs off) |
|
|
|
|
select g1000, g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
select g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
(select g%1000 as g1000, g%100 as g100, g%10 as g10, g |
|
|
|
|
from generate_series(0,199999) g) s |
|
|
|
|
group by cube (g1000,g100,g10); |
|
|
|
|
from generate_series(0,1999) g) s |
|
|
|
|
group by cube (g1000, g100,g10); |
|
|
|
|
QUERY PLAN |
|
|
|
|
--------------------------------------------------- |
|
|
|
|
MixedAggregate |
|
|
|
|
@ -1707,52 +1694,21 @@ group by cube (g1000,g100,g10); |
|
|
|
|
(10 rows) |
|
|
|
|
|
|
|
|
|
create table gs_hash_1 as |
|
|
|
|
select g1000, g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
select g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
(select g%1000 as g1000, g%100 as g100, g%10 as g10, g |
|
|
|
|
from generate_series(0,199999) g) s |
|
|
|
|
group by cube (g1000,g100,g10); |
|
|
|
|
set jit_above_cost to default; |
|
|
|
|
create table gs_hash_2 as |
|
|
|
|
select g1000, g100, g10, sum(g::numeric), count(*), max(g::text) from |
|
|
|
|
(select g/20 as g1000, g/200 as g100, g/2000 as g10, g |
|
|
|
|
from generate_series(0,19999) g) s |
|
|
|
|
group by cube (g1000,g100,g10); |
|
|
|
|
create table gs_hash_3 as |
|
|
|
|
select g100, g10, array_agg(g) as a, count(*) as c, max(g::text) as m from |
|
|
|
|
(select g/200 as g100, g/2000 as g10, g |
|
|
|
|
from generate_series(0,19999) g) s |
|
|
|
|
group by grouping sets (g100,g10); |
|
|
|
|
from generate_series(0,1999) g) s |
|
|
|
|
group by cube (g1000, g100,g10); |
|
|
|
|
set enable_sort = true; |
|
|
|
|
set work_mem to default; |
|
|
|
|
-- Compare results |
|
|
|
|
(select * from gs_hash_1 except select * from gs_group_1) |
|
|
|
|
union all |
|
|
|
|
(select * from gs_group_1 except select * from gs_hash_1); |
|
|
|
|
g1000 | g100 | g10 | sum | count | max |
|
|
|
|
-------+------+-----+-----+-------+----- |
|
|
|
|
(0 rows) |
|
|
|
|
|
|
|
|
|
(select * from gs_hash_2 except select * from gs_group_2) |
|
|
|
|
union all |
|
|
|
|
(select * from gs_group_2 except select * from gs_hash_2); |
|
|
|
|
g1000 | g100 | g10 | sum | count | max |
|
|
|
|
-------+------+-----+-----+-------+----- |
|
|
|
|
(0 rows) |
|
|
|
|
|
|
|
|
|
(select g100,g10,unnest(a),c,m from gs_hash_3 except |
|
|
|
|
select g100,g10,unnest(a),c,m from gs_group_3) |
|
|
|
|
union all |
|
|
|
|
(select g100,g10,unnest(a),c,m from gs_group_3 except |
|
|
|
|
select g100,g10,unnest(a),c,m from gs_hash_3); |
|
|
|
|
g100 | g10 | unnest | c | m |
|
|
|
|
------+-----+--------+---+--- |
|
|
|
|
g100 | g10 | sum | count | max |
|
|
|
|
------+-----+-----+-------+----- |
|
|
|
|
(0 rows) |
|
|
|
|
|
|
|
|
|
drop table gs_group_1; |
|
|
|
|
drop table gs_group_2; |
|
|
|
|
drop table gs_group_3; |
|
|
|
|
drop table gs_hash_1; |
|
|
|
|
drop table gs_hash_2; |
|
|
|
|
drop table gs_hash_3; |
|
|
|
|
SET enable_groupingsets_hash_disk TO DEFAULT; |
|
|
|
|
-- end |
|
|
|
|
|