Skip to content

Commit

Permalink
Reduce running time of jsonb_sqljson test
Browse files Browse the repository at this point in the history
The test created a 1m row table in order to test parallel operation of
JSON_VALUE. However, this was more than were needed for the test, so
save time by halving it, and also by making the table unlogged.
Experimentation shows that this size is only a little above the number
required to generate the expected output.

Per gripe from Andres Freund

Discussion: https://postgr.es/m/[email protected]
  • Loading branch information
adunstan committed Apr 6, 2022
1 parent 01effb1 commit 2ef6f11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/test/regress/expected/jsonb_sqljson.out
Original file line number Diff line number Diff line change
Expand Up @@ -2088,9 +2088,9 @@ ERROR: only string constants supported in JSON_TABLE path specification
LINE 1: SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || '...
^
-- Test parallel JSON_VALUE()
CREATE TABLE test_parallel_jsonb_value AS
CREATE UNLOGGED TABLE test_parallel_jsonb_value AS
SELECT i::text::jsonb AS js
FROM generate_series(1, 1000000) i;
FROM generate_series(1, 500000) i;
-- Should be non-parallel due to subtransactions
EXPLAIN (COSTS OFF)
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value;
Expand All @@ -2103,7 +2103,7 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric)) FROM test_parallel_jsonb_value;
sum
--------------
500000500000
125000250000
(1 row)

-- Should be parallel
Expand All @@ -2121,6 +2121,6 @@ SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_paral
SELECT sum(JSON_VALUE(js, '$' RETURNING numeric ERROR ON ERROR)) FROM test_parallel_jsonb_value;
sum
--------------
500000500000
125000250000
(1 row)

4 changes: 2 additions & 2 deletions src/test/regress/sql/jsonb_sqljson.sql
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,9 @@ SELECT JSON_QUERY(jsonb '{"a": 123}', 'error' || ' ' || 'error');
SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || 'a' COLUMNS (foo int));

-- Test parallel JSON_VALUE()
CREATE TABLE test_parallel_jsonb_value AS
CREATE UNLOGGED TABLE test_parallel_jsonb_value AS
SELECT i::text::jsonb AS js
FROM generate_series(1, 1000000) i;
FROM generate_series(1, 500000) i;

-- Should be non-parallel due to subtransactions
EXPLAIN (COSTS OFF)
Expand Down

0 comments on commit 2ef6f11

Please sign in to comment.