From e0dea27f6c9025662d229445cf84cd656185b96b Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Wed, 1 Dec 2021 14:55:26 +0900 Subject: [PATCH v4 3/3] Add regression test cases for parallel vacuum The newly added test cases test parallel vacuum on the table with different types of indexes and multiple index scans. --- src/test/regress/expected/vacuum_parallel.out | 24 +++++++++++++ src/test/regress/sql/vacuum_parallel.sql | 35 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/test/regress/expected/vacuum_parallel.out b/src/test/regress/expected/vacuum_parallel.out index ddf0ee544b..b793c247f8 100644 --- a/src/test/regress/expected/vacuum_parallel.out +++ b/src/test/regress/expected/vacuum_parallel.out @@ -47,3 +47,27 @@ RESET max_parallel_maintenance_workers; RESET min_parallel_index_scan_size; -- Deliberately don't drop table, to get further coverage from tools like -- pg_amcheck in some testing scenarios +CREATE TABLE parallel_vacuum_table2 (a int, b int4[]) WITH (autovacuum_enabled = off); +INSERT INTO parallel_vacuum_table2 SELECT g, ARRAY[1, 2, g] FROM generate_series(1, 10000) g; +-- Create different types of indexes, i.g. having different parallelvacuumoptions. +-- Also create a small index same as above. +CREATE INDEX pv_bt_index ON parallel_vacuum_table2 USING btree (a); +CREATE INDEX pv_hash_index ON parallel_vacuum_table2 USING hash (a); +CREATE INDEX pv_gin_index ON parallel_vacuum_table2 USING gin (b); +CREATE INDEX pv_brin_index ON parallel_vacuum_table2 USING brin (a); +CREATE INDEX pv_small_index ON parallel_vacuum_table2 USING btree ((1)); +-- Parallel index vacuum for various types of indexes. +DELETE FROM parallel_vacuum_table2; +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; +-- Parallel index cleanup. +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; +-- XXX: in order to execute index scan twice, we need about 200,000 garbage tuples +-- with the minimum maintenance_work_mem. However, it takes a long time to load. +INSERT INTO parallel_vacuum_table2 SELECT g, ARRAY[1, 2, g] FROM generate_series(1, 200000) g; +DELETE FROM parallel_vacuum_table2; +SET maintenance_work_mem TO 1024; +-- Parallel index vacuum for various types of indexes. +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; +-- Parallel index cleanup. +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; +RESET maintenance_work_mem; diff --git a/src/test/regress/sql/vacuum_parallel.sql b/src/test/regress/sql/vacuum_parallel.sql index 1d23f33e39..03eb8ef858 100644 --- a/src/test/regress/sql/vacuum_parallel.sql +++ b/src/test/regress/sql/vacuum_parallel.sql @@ -44,3 +44,38 @@ RESET min_parallel_index_scan_size; -- Deliberately don't drop table, to get further coverage from tools like -- pg_amcheck in some testing scenarios + +CREATE TABLE parallel_vacuum_table2 (a int, b int4[]) WITH (autovacuum_enabled = off); +INSERT INTO parallel_vacuum_table2 SELECT g, ARRAY[1, 2, g] FROM generate_series(1, 10000) g; + +-- Create different types of indexes, i.g. having different parallelvacuumoptions. +-- Also create a small index same as above. +CREATE INDEX pv_bt_index ON parallel_vacuum_table2 USING btree (a); +CREATE INDEX pv_hash_index ON parallel_vacuum_table2 USING hash (a); +CREATE INDEX pv_gin_index ON parallel_vacuum_table2 USING gin (b); +CREATE INDEX pv_brin_index ON parallel_vacuum_table2 USING brin (a); +CREATE INDEX pv_small_index ON parallel_vacuum_table2 USING btree ((1)); + + +-- Parallel index vacuum for various types of indexes. +DELETE FROM parallel_vacuum_table2; +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; + +-- Parallel index cleanup. +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; + +-- XXX: in order to execute index scan twice, we need about 200,000 garbage tuples +-- with the minimum maintenance_work_mem. However, it takes a long time to load. +INSERT INTO parallel_vacuum_table2 SELECT g, ARRAY[1, 2, g] FROM generate_series(1, 200000) g; + +DELETE FROM parallel_vacuum_table2; + +SET maintenance_work_mem TO 1024; + +-- Parallel index vacuum for various types of indexes. +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; + +-- Parallel index cleanup. +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table2; + +RESET maintenance_work_mem; -- 2.24.3 (Apple Git-128)