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
This commit is contained in:
Andrew Dunstan 2022-04-06 13:48:26 -04:00
parent a0ffa885e4
commit 14d3f24fa8
2 changed files with 28 additions and 9 deletions

View File

@ -2090,7 +2090,13 @@ LINE 1: SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || '...
-- Test parallel JSON_VALUE()
CREATE UNLOGGED TABLE test_parallel_jsonb_value AS
SELECT i::text::jsonb AS js
FROM generate_series(1, 500000) i;
FROM generate_series(1, 50000) i;
-- encourage use of parallel plans
set parallel_setup_cost=0;
set parallel_tuple_cost=0;
set min_parallel_table_scan_size=0;
set max_parallel_workers_per_gather=4;
set parallel_leader_participation = off;
-- Should be non-parallel due to subtransactions
EXPLAIN (COSTS OFF)
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
(2 rows)
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value;
sum
--------------
125000250000
sum
------------
1250025000
(1 row)
-- Should be parallel
@ -2113,14 +2119,15 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_paral
------------------------------------------------------------------
Finalize Aggregate
-> Gather
Workers Planned: 2
Workers Planned: 4
-> Partial Aggregate
-> Parallel Seq Scan on test_parallel_jsonb_value
(5 rows)
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
sum
--------------
125000250000
sum
------------
1250025000
(1 row)
DROP TABLE test_parallel_jsonb_value;

View File

@ -948,9 +948,19 @@ SELECT JSON_QUERY(jsonb '{"a": 123}', 'error' || ' ' || 'error');
SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || 'a' COLUMNS (foo int));
-- Test parallel JSON_VALUE()
CREATE UNLOGGED TABLE test_parallel_jsonb_value AS
SELECT i::text::jsonb AS js
FROM generate_series(1, 500000) i;
FROM generate_series(1, 50000) i;
-- encourage use of parallel plans
set parallel_setup_cost=0;
set parallel_tuple_cost=0;
set min_parallel_table_scan_size=0;
set max_parallel_workers_per_gather=4;
set parallel_leader_participation = off;
-- Should be non-parallel due to subtransactions
EXPLAIN (COSTS OFF)
@ -961,3 +971,5 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value
EXPLAIN (COSTS OFF)
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
DROP TABLE test_parallel_jsonb_value;