Skip to content

Commit

Permalink
multi-mx test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
m7hm7t committed Nov 5, 2024
1 parent 6c12b10 commit fd66a7d
Show file tree
Hide file tree
Showing 7 changed files with 3,950 additions and 21 deletions.
383 changes: 383 additions & 0 deletions src/test/regress/expected/ch_bench_having_mx_0.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,383 @@
-- Two alternative test outputs:
-- ch_bench_having_mx.out for PG16 and before
-- ch_bench_having_mx_0.out for PG17
-- related commit
-- https://github.com/postgres/postgres/commit/fd0398fc
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 1640000;
SET citus.shard_replication_factor to 1;
SET citus.shard_count to 4;
CREATE SCHEMA ch_bench_having;
SET search_path = ch_bench_having;
CREATE TABLE stock (
s_w_id int NOT NULL,
s_i_id int NOT NULL,
s_order_cnt int NOT NULL
);
SELECT create_distributed_table('stock','s_w_id');
create_distributed_table
---------------------------------------------------------------------

(1 row)

\c - - - :worker_1_port
SET search_path = ch_bench_having;
explain (costs false, summary false, timing false)
select s_i_id, sum(s_order_cnt) as ordercount
from stock
where s_order_cnt > (select sum(s_order_cnt) * .005 as where_query from stock)
group by s_i_id
having sum(s_order_cnt) > (select max(s_order_cnt) - 3 as having_query from stock)
order by s_i_id;
QUERY PLAN
---------------------------------------------------------------------
Sort
Sort Key: remote_scan.s_i_id
InitPlan 1
-> Function Scan on read_intermediate_result intermediate_result
-> HashAggregate
Group Key: remote_scan.s_i_id
Filter: ((pg_catalog.sum(remote_scan.worker_column_3))::bigint > (InitPlan 1).col1)
-> Custom Scan (Citus Adaptive)
-> Distributed Subplan XXX_1
-> Aggregate
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Seq Scan on stock_1640000 stock
-> Distributed Subplan XXX_2
-> Aggregate
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Seq Scan on stock_1640000 stock
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> HashAggregate
Group Key: stock.s_i_id
InitPlan 1
-> Function Scan on read_intermediate_result intermediate_result
-> Seq Scan on stock_1640000 stock
Filter: ((s_order_cnt)::numeric > (InitPlan 1).col1)
(36 rows)

explain (costs false, summary false, timing false)
select s_i_id, sum(s_order_cnt) as ordercount
from stock
group by s_i_id
having sum(s_order_cnt) > (select max(s_order_cnt) - 3 as having_query from stock)
order by s_i_id;
QUERY PLAN
---------------------------------------------------------------------
Sort
Sort Key: remote_scan.s_i_id
InitPlan 1
-> Function Scan on read_intermediate_result intermediate_result
-> HashAggregate
Group Key: remote_scan.s_i_id
Filter: ((pg_catalog.sum(remote_scan.worker_column_3))::bigint > (InitPlan 1).col1)
-> Custom Scan (Citus Adaptive)
-> Distributed Subplan XXX_1
-> Aggregate
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Seq Scan on stock_1640000 stock
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> HashAggregate
Group Key: stock.s_i_id
-> Seq Scan on stock_1640000 stock
(24 rows)

explain (costs false, summary false, timing false)
select s_i_id, sum(s_order_cnt) as ordercount
from stock
group by s_i_id
having sum(s_order_cnt) > (select max(s_order_cnt) - 3 as having_query from stock);
QUERY PLAN
---------------------------------------------------------------------
HashAggregate
Group Key: remote_scan.s_i_id
Filter: ((pg_catalog.sum(remote_scan.worker_column_3))::bigint > (InitPlan 1).col1)
InitPlan 1
-> Function Scan on read_intermediate_result intermediate_result
-> Custom Scan (Citus Adaptive)
-> Distributed Subplan XXX_1
-> Aggregate
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Seq Scan on stock_1640000 stock
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> HashAggregate
Group Key: stock.s_i_id
-> Seq Scan on stock_1640000 stock
(22 rows)

explain (costs false)
select s_i_id, sum(s_order_cnt) as ordercount
from stock s
group by s_i_id
having (select true)
order by s_i_id;
QUERY PLAN
---------------------------------------------------------------------
Sort
Sort Key: remote_scan.s_i_id
InitPlan 1
-> Result
-> HashAggregate
Group Key: remote_scan.s_i_id
-> Result
One-Time Filter: (InitPlan 1).col1
-> Custom Scan (Citus Adaptive)
Filter: (InitPlan 1).col1
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> HashAggregate
Group Key: s.s_i_id
-> Seq Scan on stock_1640000 s
(17 rows)

explain select s_i_id, sum(s_order_cnt) as ordercount
from stock s
group by s_i_id
having (select true);
QUERY PLAN
---------------------------------------------------------------------
HashAggregate (cost=500.01..503.01 rows=200 width=12)
Group Key: remote_scan.s_i_id
InitPlan 1
-> Result (cost=0.00..0.01 rows=1 width=1)
-> Result (cost=0.00..0.00 rows=100000 width=12)
One-Time Filter: (InitPlan 1).col1
-> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=12)
Filter: (InitPlan 1).col1
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> HashAggregate (cost=40.60..42.60 rows=200 width=12)
Group Key: s.s_i_id
-> Seq Scan on stock_1640000 s (cost=0.00..30.40 rows=2040 width=8)
(15 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock
where s_order_cnt > (select sum(s_order_cnt) * .005 as where_query from stock)
group by s_i_id
having sum(s_order_cnt) > (select max(s_order_cnt) - 3 as having_query from stock)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
(0 rows)

INSERT INTO stock SELECT c, c, c FROM generate_series(1, 5) as c;
select s_i_id, sum(s_order_cnt) as ordercount
from stock
where s_order_cnt > (select sum(s_order_cnt) * .005 as where_query from stock)
group by s_i_id
having sum(s_order_cnt) > (select max(s_order_cnt) - 3 as having_query from stock)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
3 | 3
4 | 4
5 | 5
(3 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock
group by s_i_id
having sum(s_order_cnt) > (select max(s_order_cnt) - 3 as having_query from stock)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
3 | 3
4 | 4
5 | 5
(3 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock s
where s_order_cnt > (select sum(s_order_cnt) * .005 as where_query from stock)
group by s_i_id
having (select true)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
(5 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock s
where s_order_cnt > (select sum(s_order_cnt) * .005 as where_query from stock)
group by s_i_id
having (select false)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
(0 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock s
group by s_i_id
having (select true)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
(5 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock s
group by s_i_id
having (select false)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
(0 rows)

select s_i_id, sum(s_order_cnt) as ordercount
from stock s
group by s_i_id
having (select true)
order by s_i_id;
s_i_id | ordercount
---------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
(5 rows)

-- We don't support correlated subqueries in having
select s_i_id, sum(s_order_cnt) as ordercount
from stock s
where s_order_cnt > (select sum(s_order_cnt) * .005 as where_query from stock)
group by s_i_id
having (select max(s_order_cnt) > 2 as having_query from stock where s_i_id = s.s_i_id)
order by s_i_id;
ERROR: Subqueries in HAVING cannot refer to outer query
-- We don't support correlated subqueries in having
select s_i_id, sum(s_order_cnt) as ordercount
from stock s
group by s_i_id
having (select max(s_order_cnt) > 2 as having_query from stock where s_i_id = s.s_i_id)
order by s_i_id;
ERROR: Subqueries in HAVING cannot refer to outer query
\c - - - :master_port
SET citus.shard_replication_factor to 1;
SET citus.shard_count to 4;
SET search_path = ch_bench_having, public;
DROP TABLE stock;
CREATE TABLE stock (
s_w_id int NOT NULL,
s_i_id int NOT NULL,
s_quantity decimal(4,0) NOT NULL,
s_ytd decimal(8,2) NOT NULL,
s_order_cnt int NOT NULL,
s_remote_cnt int NOT NULL,
s_data varchar(50) NOT NULL,
s_dist_01 char(24) NOT NULL,
s_dist_02 char(24) NOT NULL,
s_dist_03 char(24) NOT NULL,
s_dist_04 char(24) NOT NULL,
s_dist_05 char(24) NOT NULL,
s_dist_06 char(24) NOT NULL,
s_dist_07 char(24) NOT NULL,
s_dist_08 char(24) NOT NULL,
s_dist_09 char(24) NOT NULL,
s_dist_10 char(24) NOT NULL,
PRIMARY KEY (s_w_id,s_i_id)
);
insert into stock VALUES
(1, 33, 1, 1, 1, 1, '', '','','','','','','','','',''),
(33, 1, 1, 1, 1, 1, '', '','','','','','','','','',''),
(32, 1, 1, 1, 1, 1, '', '','','','','','','','','','');
SELECT create_distributed_table('stock','s_w_id');
NOTICE: Copying data from local table...
NOTICE: copying the data has completed
DETAIL: The local data in the table is no longer visible, but is still on disk.
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$ch_bench_having.stock$$)
create_distributed_table
---------------------------------------------------------------------

(1 row)

\c - - - :worker_1_port
SET search_path = ch_bench_having, public;
select s_i_id, sum(s_order_cnt) as ordercount
from stock, supplier_mx, nation_mx
where mod((s_w_id * s_i_id),10000) = s_suppkey
and s_nationkey = n_nationkey
and n_name = 'GERMANY'
group by s_i_id
having sum(s_order_cnt) >
(select sum(s_order_cnt) * .005
from stock, supplier_mx, nation_mx
where mod((s_w_id * s_i_id),10000) = s_suppkey
and s_nationkey = n_nationkey
and n_name = 'GERMANY')
order by s_i_id, ordercount desc;
s_i_id | ordercount
---------------------------------------------------------------------
1 | 1
33 | 1
(2 rows)

insert into stock VALUES
(10033, 1, 1, 1, 100000, 1, '', '','','','','','','','','','');
select s_i_id, sum(s_order_cnt) as ordercount
from stock, supplier_mx, nation_mx
where mod((s_w_id * s_i_id),10000) = s_suppkey
and s_nationkey = n_nationkey
and n_name = 'GERMANY'
group by s_i_id
having sum(s_order_cnt) >
(select sum(s_order_cnt) * .005
from stock, supplier_mx, nation_mx
where mod((s_w_id * s_i_id),10000) = s_suppkey
and s_nationkey = n_nationkey
and n_name = 'GERMANY')
order by s_i_id, ordercount desc;
s_i_id | ordercount
---------------------------------------------------------------------
1 | 100001
(1 row)

\c - - - :master_port
BEGIN;
SET LOCAL client_min_messages TO WARNING;
DROP SCHEMA ch_bench_having CASCADE;
COMMIT;
Loading

0 comments on commit fd66a7d

Please sign in to comment.