Use debug_parallel_query in PG16+, force_parallel_mode otherwise

Relevant PG commit
5352ca22e0
5352ca22e0012d48055453ca9992a9515d811291
naisila/check_router_fix
naisila 2023-05-25 15:42:43 +03:00
parent 14181072cf
commit 286816f7c3
8 changed files with 97 additions and 6 deletions

View File

@ -1,5 +1,6 @@
-- test for Postgres version --
-- should error before PG12 -- ALTER_TABLE_SET_ACCESS_METHOD
--
CREATE TABLE alter_am_pg_version_table (a INT); CREATE TABLE alter_am_pg_version_table (a INT);
SELECT alter_table_set_access_method('alter_am_pg_version_table', 'columnar'); SELECT alter_table_set_access_method('alter_am_pg_version_table', 'columnar');
NOTICE: creating a new table for public.alter_am_pg_version_table NOTICE: creating a new table for public.alter_am_pg_version_table
@ -770,8 +771,15 @@ RESET client_min_messages;
create table events (event_id bigserial, event_time timestamptz default now(), payload text); create table events (event_id bigserial, event_time timestamptz default now(), payload text);
create index on events (event_id); create index on events (event_id);
insert into events (payload) select 'hello-'||s from generate_series(1,10) s; insert into events (payload) select 'hello-'||s from generate_series(1,10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
BEGIN; BEGIN;
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress; SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1; SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0; SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4; SET LOCAL max_parallel_workers = 4;

View File

@ -21,7 +21,14 @@ select count(*), min(i), max(i), avg(i) from fallback_scan;
-- Negative test: try to force a parallel plan with at least two -- Negative test: try to force a parallel plan with at least two
-- workers, but columnar should reject it and use a non-parallel scan. -- workers, but columnar should reject it and use a non-parallel scan.
-- --
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
set debug_parallel_query = regress;
\else
set force_parallel_mode = regress; set force_parallel_mode = regress;
\endif
set min_parallel_table_scan_size = 1; set min_parallel_table_scan_size = 1;
set parallel_tuple_cost = 0; set parallel_tuple_cost = 0;
set max_parallel_workers = 4; set max_parallel_workers = 4;
@ -39,7 +46,11 @@ select count(*), min(i), max(i), avg(i) from fallback_scan;
150000 | 1 | 150000 | 75000.500000000000 150000 | 1 | 150000 | 75000.500000000000
(1 row) (1 row)
set force_parallel_mode to default; \if :server_version_ge_16
set debug_parallel_query = default;
\else
set force_parallel_mode = default;
\endif
set min_parallel_table_scan_size to default; set min_parallel_table_scan_size to default;
set parallel_tuple_cost to default; set parallel_tuple_cost to default;
set max_parallel_workers to default; set max_parallel_workers to default;

View File

@ -1,4 +1,6 @@
-- --
-- COLUMNAR_INDEXES
--
-- Testing indexes on on columnar tables. -- Testing indexes on on columnar tables.
-- --
CREATE SCHEMA columnar_indexes; CREATE SCHEMA columnar_indexes;
@ -598,6 +600,9 @@ create table events (event_id bigserial, event_time timestamptz default now(), p
BEGIN; BEGIN;
-- this wouldn't flush any data -- this wouldn't flush any data
insert into events (payload) select 'hello-'||s from generate_series(1, 10) s; insert into events (payload) select 'hello-'||s from generate_series(1, 10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- Since table is large enough, normally postgres would prefer using -- Since table is large enough, normally postgres would prefer using
-- parallel workers when building the index. -- parallel workers when building the index.
-- --
@ -609,7 +614,11 @@ BEGIN;
-- by postgres and throws an error. For this reason, here we don't expect -- by postgres and throws an error. For this reason, here we don't expect
-- following commnad to fail since we prevent using parallel workers for -- following commnad to fail since we prevent using parallel workers for
-- columnar tables. -- columnar tables.
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress; SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1; SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0; SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4; SET LOCAL max_parallel_workers = 4;

View File

@ -1,3 +1,6 @@
--
-- COLUMNAR_PARTITIONING
--
CREATE TABLE parent(ts timestamptz, i int, n numeric, s text) CREATE TABLE parent(ts timestamptz, i int, n numeric, s text)
PARTITION BY RANGE (ts); PARTITION BY RANGE (ts);
-- row partitions -- row partitions
@ -17,8 +20,15 @@ INSERT INTO parent SELECT '2020-03-15', 30, 300, 'three thousand'
FROM generate_series(1,100000); FROM generate_series(1,100000);
INSERT INTO parent SELECT '2020-04-15', 30, 300, 'three thousand' INSERT INTO parent SELECT '2020-04-15', 30, 300, 'three thousand'
FROM generate_series(1,100000); FROM generate_series(1,100000);
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- run parallel plans -- run parallel plans
\if :server_version_ge_16
SET debug_parallel_query = regress;
\else
SET force_parallel_mode = regress; SET force_parallel_mode = regress;
\endif
SET min_parallel_table_scan_size = 1; SET min_parallel_table_scan_size = 1;
SET parallel_tuple_cost = 0; SET parallel_tuple_cost = 0;
SET max_parallel_workers = 4; SET max_parallel_workers = 4;
@ -121,7 +131,11 @@ SELECT count(*), sum(i), min(i), max(i) FROM parent;
(1 row) (1 row)
SET columnar.enable_custom_scan TO DEFAULT; SET columnar.enable_custom_scan TO DEFAULT;
\if :server_version_ge_16
SET debug_parallel_query TO DEFAULT;
\else
SET force_parallel_mode TO DEFAULT; SET force_parallel_mode TO DEFAULT;
\endif
SET min_parallel_table_scan_size TO DEFAULT; SET min_parallel_table_scan_size TO DEFAULT;
SET parallel_tuple_cost TO DEFAULT; SET parallel_tuple_cost TO DEFAULT;
SET max_parallel_workers TO DEFAULT; SET max_parallel_workers TO DEFAULT;

View File

@ -1,5 +1,7 @@
-- test for Postgres version --
-- should error before PG12 -- ALTER_TABLE_SET_ACCESS_METHOD
--
CREATE TABLE alter_am_pg_version_table (a INT); CREATE TABLE alter_am_pg_version_table (a INT);
SELECT alter_table_set_access_method('alter_am_pg_version_table', 'columnar'); SELECT alter_table_set_access_method('alter_am_pg_version_table', 'columnar');
DROP TABLE alter_am_pg_version_table; DROP TABLE alter_am_pg_version_table;
@ -258,8 +260,16 @@ create table events (event_id bigserial, event_time timestamptz default now(), p
create index on events (event_id); create index on events (event_id);
insert into events (payload) select 'hello-'||s from generate_series(1,10) s; insert into events (payload) select 'hello-'||s from generate_series(1,10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
BEGIN; BEGIN;
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress; SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1; SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0; SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4; SET LOCAL max_parallel_workers = 4;

View File

@ -20,7 +20,16 @@ select count(*), min(i), max(i), avg(i) from fallback_scan;
-- Negative test: try to force a parallel plan with at least two -- Negative test: try to force a parallel plan with at least two
-- workers, but columnar should reject it and use a non-parallel scan. -- workers, but columnar should reject it and use a non-parallel scan.
-- --
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
set debug_parallel_query = regress;
\else
set force_parallel_mode = regress; set force_parallel_mode = regress;
\endif
set min_parallel_table_scan_size = 1; set min_parallel_table_scan_size = 1;
set parallel_tuple_cost = 0; set parallel_tuple_cost = 0;
set max_parallel_workers = 4; set max_parallel_workers = 4;
@ -28,7 +37,11 @@ set max_parallel_workers_per_gather = 4;
explain (costs off) select count(*), min(i), max(i), avg(i) from fallback_scan; explain (costs off) select count(*), min(i), max(i), avg(i) from fallback_scan;
select count(*), min(i), max(i), avg(i) from fallback_scan; select count(*), min(i), max(i), avg(i) from fallback_scan;
set force_parallel_mode to default; \if :server_version_ge_16
set debug_parallel_query = default;
\else
set force_parallel_mode = default;
\endif
set min_parallel_table_scan_size to default; set min_parallel_table_scan_size to default;
set parallel_tuple_cost to default; set parallel_tuple_cost to default;
set max_parallel_workers to default; set max_parallel_workers to default;

View File

@ -1,4 +1,6 @@
-- --
-- COLUMNAR_INDEXES
--
-- Testing indexes on on columnar tables. -- Testing indexes on on columnar tables.
-- --
@ -448,6 +450,10 @@ BEGIN;
-- this wouldn't flush any data -- this wouldn't flush any data
insert into events (payload) select 'hello-'||s from generate_series(1, 10) s; insert into events (payload) select 'hello-'||s from generate_series(1, 10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- Since table is large enough, normally postgres would prefer using -- Since table is large enough, normally postgres would prefer using
-- parallel workers when building the index. -- parallel workers when building the index.
-- --
@ -459,7 +465,12 @@ BEGIN;
-- by postgres and throws an error. For this reason, here we don't expect -- by postgres and throws an error. For this reason, here we don't expect
-- following commnad to fail since we prevent using parallel workers for -- following commnad to fail since we prevent using parallel workers for
-- columnar tables. -- columnar tables.
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress; SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1; SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0; SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4; SET LOCAL max_parallel_workers = 4;

View File

@ -1,3 +1,6 @@
--
-- COLUMNAR_PARTITIONING
--
CREATE TABLE parent(ts timestamptz, i int, n numeric, s text) CREATE TABLE parent(ts timestamptz, i int, n numeric, s text)
PARTITION BY RANGE (ts); PARTITION BY RANGE (ts);
@ -21,8 +24,16 @@ INSERT INTO parent SELECT '2020-03-15', 30, 300, 'three thousand'
INSERT INTO parent SELECT '2020-04-15', 30, 300, 'three thousand' INSERT INTO parent SELECT '2020-04-15', 30, 300, 'three thousand'
FROM generate_series(1,100000); FROM generate_series(1,100000);
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- run parallel plans -- run parallel plans
\if :server_version_ge_16
SET debug_parallel_query = regress;
\else
SET force_parallel_mode = regress; SET force_parallel_mode = regress;
\endif
SET min_parallel_table_scan_size = 1; SET min_parallel_table_scan_size = 1;
SET parallel_tuple_cost = 0; SET parallel_tuple_cost = 0;
SET max_parallel_workers = 4; SET max_parallel_workers = 4;
@ -46,7 +57,11 @@ EXPLAIN (costs off) SELECT count(*), sum(i), min(i), max(i) FROM parent;
SELECT count(*), sum(i), min(i), max(i) FROM parent; SELECT count(*), sum(i), min(i), max(i) FROM parent;
SET columnar.enable_custom_scan TO DEFAULT; SET columnar.enable_custom_scan TO DEFAULT;
\if :server_version_ge_16
SET debug_parallel_query TO DEFAULT;
\else
SET force_parallel_mode TO DEFAULT; SET force_parallel_mode TO DEFAULT;
\endif
SET min_parallel_table_scan_size TO DEFAULT; SET min_parallel_table_scan_size TO DEFAULT;
SET parallel_tuple_cost TO DEFAULT; SET parallel_tuple_cost TO DEFAULT;
SET max_parallel_workers TO DEFAULT; SET max_parallel_workers TO DEFAULT;