diff --git a/src/test/regress/expected/multi_utilities.out b/src/test/regress/expected/multi_utilities.out index cfaba201f..76d5da1a2 100644 --- a/src/test/regress/expected/multi_utilities.out +++ b/src/test/regress/expected/multi_utilities.out @@ -347,24 +347,14 @@ DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -- should not propagate because no distributed table is specified insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; --- sometimes the vacuum doesn't clean up as expected and results in a flaky result --- for our tests. For this reason, we re-run the vacuum command once if size of --- the table before and after the VACUUM is not as expected -SELECT pg_total_relation_size('local_vacuum_table') AS size_before_vacuum \gset -VACUUM local_vacuum_table; -SELECT pg_total_relation_size('local_vacuum_table') AS size_after_vacuum \gset -SELECT :size_before_vacuum <= :size_after_vacuum AS re_vacuum_needed \gset -\if :re_vacuum_needed -SELECT pg_total_relation_size('local_vacuum_table') AS size_before_vacuum \gset VACUUM local_vacuum_table; VACUUM local_vacuum_table; VACUUM local_vacuum_table; -SELECT pg_total_relation_size('local_vacuum_table') AS size_after_vacuum \gset -\endif -SELECT :size_before_vacuum > :size_after_vacuum AS vacuum_successful; - vacuum_successful +SELECT CASE WHEN s BETWEEN 20000000 AND 49999999 THEN 35000000 ELSE s END size +FROM pg_total_relation_size('local_vacuum_table') s ; + size --------------------------------------------------------------------- - t + 35000000 (1 row) -- vacuum full deallocates pages of dead tuples whereas normal vacuum only marks dead tuples on visibility map @@ -413,6 +403,8 @@ VACUUM (DISABLE_PAGE_SKIPPING false) local_vacuum_table; insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; VACUUM (INDEX_CLEANUP OFF, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP OFF, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP OFF, PARALLEL 1) local_vacuum_table; SELECT CASE WHEN s BETWEEN 50000000 AND 70000000 THEN 60000000 ELSE s END size FROM pg_total_relation_size('local_vacuum_table') s ; size @@ -423,6 +415,8 @@ FROM pg_total_relation_size('local_vacuum_table') s ; insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table; SELECT CASE WHEN s BETWEEN 20000000 AND 49999999 THEN 35000000 ELSE s END size FROM pg_total_relation_size('local_vacuum_table') s ; size @@ -434,10 +428,14 @@ FROM pg_total_relation_size('local_vacuum_table') s ; insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; vacuum (TRUNCATE false) local_vacuum_table; +vacuum (TRUNCATE false) local_vacuum_table; +vacuum (TRUNCATE false) local_vacuum_table; SELECT pg_total_relation_size('local_vacuum_table') as size1 \gset insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; vacuum (TRUNCATE true) local_vacuum_table; +vacuum (TRUNCATE true) local_vacuum_table; +vacuum (TRUNCATE true) local_vacuum_table; SELECT pg_total_relation_size('local_vacuum_table') as size2 \gset SELECT :size1 > :size2 as truncate_less_size; truncate_less_size diff --git a/src/test/regress/sql/multi_utilities.sql b/src/test/regress/sql/multi_utilities.sql index 6b66b19dc..917f69756 100644 --- a/src/test/regress/sql/multi_utilities.sql +++ b/src/test/regress/sql/multi_utilities.sql @@ -228,24 +228,11 @@ VACUUM; -- should not propagate because no distributed table is specified insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; - --- sometimes the vacuum doesn't clean up as expected and results in a flaky result --- for our tests. For this reason, we re-run the vacuum command once if size of --- the table before and after the VACUUM is not as expected -SELECT pg_total_relation_size('local_vacuum_table') AS size_before_vacuum \gset -VACUUM local_vacuum_table; -SELECT pg_total_relation_size('local_vacuum_table') AS size_after_vacuum \gset - -SELECT :size_before_vacuum <= :size_after_vacuum AS re_vacuum_needed \gset -\if :re_vacuum_needed -SELECT pg_total_relation_size('local_vacuum_table') AS size_before_vacuum \gset VACUUM local_vacuum_table; VACUUM local_vacuum_table; VACUUM local_vacuum_table; -SELECT pg_total_relation_size('local_vacuum_table') AS size_after_vacuum \gset -\endif - -SELECT :size_before_vacuum > :size_after_vacuum AS vacuum_successful; +SELECT CASE WHEN s BETWEEN 20000000 AND 49999999 THEN 35000000 ELSE s END size +FROM pg_total_relation_size('local_vacuum_table') s ; -- vacuum full deallocates pages of dead tuples whereas normal vacuum only marks dead tuples on visibility map VACUUM FULL local_vacuum_table; @@ -272,12 +259,16 @@ VACUUM (DISABLE_PAGE_SKIPPING false) local_vacuum_table; insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; VACUUM (INDEX_CLEANUP OFF, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP OFF, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP OFF, PARALLEL 1) local_vacuum_table; SELECT CASE WHEN s BETWEEN 50000000 AND 70000000 THEN 60000000 ELSE s END size FROM pg_total_relation_size('local_vacuum_table') s ; insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table; +VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table; SELECT CASE WHEN s BETWEEN 20000000 AND 49999999 THEN 35000000 ELSE s END size FROM pg_total_relation_size('local_vacuum_table') s ; @@ -285,11 +276,15 @@ FROM pg_total_relation_size('local_vacuum_table') s ; insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; vacuum (TRUNCATE false) local_vacuum_table; +vacuum (TRUNCATE false) local_vacuum_table; +vacuum (TRUNCATE false) local_vacuum_table; SELECT pg_total_relation_size('local_vacuum_table') as size1 \gset insert into local_vacuum_table select i from generate_series(1,1000000) i; delete from local_vacuum_table; vacuum (TRUNCATE true) local_vacuum_table; +vacuum (TRUNCATE true) local_vacuum_table; +vacuum (TRUNCATE true) local_vacuum_table; SELECT pg_total_relation_size('local_vacuum_table') as size2 \gset SELECT :size1 > :size2 as truncate_less_size;