Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 14d3f24

Browse files
committed
Further improve jsonb_sqljson parallel test
Instead of using a very large table, use some settings to encourage use of parallelism. Also, drop the table so it doesn't upset the recovery test. per suggestion from Andres Freund Discussion: https://postgr.es/m/20220406022118.3ocqvhxr6kciw5am@alap3.anarazel.de
1 parent a0ffa88 commit 14d3f24

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/test/regress/expected/jsonb_sqljson.out

+15-8
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,13 @@ LINE 1: SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || '...
20902090
-- Test parallel JSON_VALUE()
20912091
CREATE UNLOGGED TABLE test_parallel_jsonb_value AS
20922092
SELECT i::text::jsonb AS js
2093-
FROM generate_series(1, 500000) i;
2093+
FROM generate_series(1, 50000) i;
2094+
-- encourage use of parallel plans
2095+
set parallel_setup_cost=0;
2096+
set parallel_tuple_cost=0;
2097+
set min_parallel_table_scan_size=0;
2098+
set max_parallel_workers_per_gather=4;
2099+
set parallel_leader_participation = off;
20942100
-- Should be non-parallel due to subtransactions
20952101
EXPLAIN (COSTS OFF)
20962102
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value;
@@ -2101,9 +2107,9 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value
21012107
(2 rows)
21022108

21032109
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value;
2104-
sum
2105-
--------------
2106-
125000250000
2110+
sum
2111+
------------
2112+
1250025000
21072113
(1 row)
21082114

21092115
-- Should be parallel
@@ -2113,14 +2119,15 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_paral
21132119
------------------------------------------------------------------
21142120
Finalize Aggregate
21152121
-> Gather
2116-
Workers Planned: 2
2122+
Workers Planned: 4
21172123
-> Partial Aggregate
21182124
-> Parallel Seq Scan on test_parallel_jsonb_value
21192125
(5 rows)
21202126

21212127
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
2122-
sum
2123-
--------------
2124-
125000250000
2128+
sum
2129+
------------
2130+
1250025000
21252131
(1 row)
21262132

2133+
DROP TABLE test_parallel_jsonb_value;

src/test/regress/sql/jsonb_sqljson.sql

+13-1
Original file line numberDiff line numberDiff line change
@@ -948,9 +948,19 @@ SELECT JSON_QUERY(jsonb '{"a": 123}', 'error' || ' ' || 'error');
948948
SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || 'a' COLUMNS (foo int));
949949

950950
-- Test parallel JSON_VALUE()
951+
952+
951953
CREATE UNLOGGED TABLE test_parallel_jsonb_value AS
952954
SELECT i::text::jsonb AS js
953-
FROM generate_series(1, 500000) i;
955+
FROM generate_series(1, 50000) i;
956+
957+
958+
-- encourage use of parallel plans
959+
set parallel_setup_cost=0;
960+
set parallel_tuple_cost=0;
961+
set min_parallel_table_scan_size=0;
962+
set max_parallel_workers_per_gather=4;
963+
set parallel_leader_participation = off;
954964

955965
-- Should be non-parallel due to subtransactions
956966
EXPLAIN (COSTS OFF)
@@ -961,3 +971,5 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value
961971
EXPLAIN (COSTS OFF)
962972
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
963973
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
974+
975+
DROP TABLE test_parallel_jsonb_value;

0 commit comments

Comments
 (0)