Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce59b75

Browse files
committed
Add toast-level reloption for vacuum_index_cleanup
a96c41f has introduced the option for heap, but it still lacked thevariant to control the behavior for toast relations.While on it, refactor the tests so as they stress more scenarios withthe various values that vacuum_index_cleanup can use. It would beuseful to couple those tests with pageinspect to check that pages areactually cleaned up, but this is left for later.Author: Masahiko Sawada, Michael PaquierReviewed-by: Peter GeogheganDiscussion:https://postgr.es/m/CAD21AoCqs8iN04RX=i1KtLSaX5RrTEM04b7NHYps4+rqtpWNEg@mail.gmail.com
1 parent0089c30 commitce59b75

File tree

5 files changed

+63
-10
lines changed

5 files changed

+63
-10
lines changed

‎doc/src/sgml/ref/create_table.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
14061406
</varlistentry>
14071407

14081408
<varlistentry id="reloption-vacuum-index-cleanup" xreflabel="vacuum_index_cleanup">
1409-
<term><literal>vacuum_index_cleanup</literal> (<type>boolean</type>)
1409+
<term><literal>vacuum_index_cleanup</literal>, <literal>toast.vacuum_index_cleanup</literal> (<type>boolean</type>)
14101410
<indexterm>
14111411
<primary><varname>vacuum_index_cleanup</varname> storage parameter</primary>
14121412
</indexterm>

‎src/backend/access/common/reloptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static relopt_bool boolRelOpts[] =
144144
{
145145
"vacuum_index_cleanup",
146146
"Enables index vacuuming and index cleanup",
147-
RELOPT_KIND_HEAP,
147+
RELOPT_KIND_HEAP |RELOPT_KIND_TOAST,
148148
ShareUpdateExclusiveLock
149149
},
150150
true

‎src/bin/psql/tab-complete.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,7 @@ static const char *const table_storage_parameters[] = {
10691069
"toast.autovacuum_vacuum_scale_factor",
10701070
"toast.autovacuum_vacuum_threshold",
10711071
"toast.log_autovacuum_min_duration",
1072+
"toast.vacuum_index_cleanup",
10721073
"toast.vacuum_truncate",
10731074
"toast_tuple_target",
10741075
"user_catalog_table",

‎src/test/regress/expected/vacuum.out

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,39 @@ SQL function "wrap_do_analyze" statement 1
9393
VACUUM FULL vactst;
9494
VACUUM (DISABLE_PAGE_SKIPPING) vaccluster;
9595
-- INDEX_CLEANUP option
96-
CREATE TABLE no_index_cleanup (i INT PRIMARY KEY) WITH (vacuum_index_cleanup = false);
97-
VACUUM (INDEX_CLEANUP FALSE) vaccluster;
98-
VACUUM (INDEX_CLEANUP FALSE) vactst; -- index cleanup option is ignored if no indexes
99-
VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster;
96+
CREATE TABLE no_index_cleanup (i INT PRIMARY KEY, t TEXT);
97+
-- Use uncompressed data stored in toast.
98+
CREATE INDEX no_index_cleanup_idx ON no_index_cleanup(t);
99+
ALTER TABLE no_index_cleanup ALTER COLUMN t SET STORAGE EXTERNAL;
100+
INSERT INTO no_index_cleanup(i, t) VALUES (generate_series(1,30),
101+
repeat('1234567890',300));
100102
-- index cleanup option is ignored if VACUUM FULL
101103
VACUUM (INDEX_CLEANUP TRUE, FULL TRUE) no_index_cleanup;
102104
VACUUM (FULL TRUE) no_index_cleanup;
105+
-- Toast inherits the value from its parent table.
106+
ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = false);
107+
DELETE FROM no_index_cleanup WHERE i < 15;
108+
-- Nothing is cleaned up.
109+
VACUUM no_index_cleanup;
110+
-- Both parent relation and toast are cleaned up.
111+
ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = true);
112+
VACUUM no_index_cleanup;
113+
-- Parameter is set for both the parent table and its toast relation.
114+
INSERT INTO no_index_cleanup(i, t) VALUES (generate_series(31,60),
115+
repeat('1234567890',300));
116+
DELETE FROM no_index_cleanup WHERE i < 45;
117+
-- Only toast index is cleaned up.
118+
ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = false,
119+
toast.vacuum_index_cleanup = true);
120+
VACUUM no_index_cleanup;
121+
-- Only parent is cleaned up.
122+
ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = true,
123+
toast.vacuum_index_cleanup = false);
124+
VACUUM no_index_cleanup;
125+
-- Test some extra relations.
126+
VACUUM (INDEX_CLEANUP FALSE) vaccluster;
127+
VACUUM (INDEX_CLEANUP FALSE) vactst; -- index cleanup option is ignored if no indexes
128+
VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster;
103129
-- TRUNCATE option
104130
CREATE TABLE vac_truncate_test(i INT NOT NULL, j text)
105131
WITH (vacuum_truncate=true, autovacuum_enabled=false);

‎src/test/regress/sql/vacuum.sql

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,39 @@ VACUUM FULL vactst;
7676
VACUUM (DISABLE_PAGE_SKIPPING) vaccluster;
7777

7878
-- INDEX_CLEANUP option
79-
CREATETABLEno_index_cleanup (iINTPRIMARY KEY) WITH (vacuum_index_cleanup= false);
80-
VACUUM (INDEX_CLEANUP FALSE) vaccluster;
81-
VACUUM (INDEX_CLEANUP FALSE) vactst;-- index cleanup option is ignored if no indexes
82-
VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster;
79+
CREATETABLEno_index_cleanup (iINTPRIMARY KEY, tTEXT);
80+
-- Use uncompressed data stored in toast.
81+
CREATEINDEXno_index_cleanup_idxON no_index_cleanup(t);
82+
ALTERTABLE no_index_cleanup ALTER COLUMN tSET STORAGE EXTERNAL;
83+
INSERT INTO no_index_cleanup(i, t)VALUES (generate_series(1,30),
84+
repeat('1234567890',300));
8385
-- index cleanup option is ignored if VACUUM FULL
8486
VACUUM (INDEX_CLEANUP TRUE, FULL TRUE) no_index_cleanup;
8587
VACUUM (FULL TRUE) no_index_cleanup;
88+
-- Toast inherits the value from its parent table.
89+
ALTERTABLE no_index_cleanupSET (vacuum_index_cleanup= false);
90+
DELETEFROM no_index_cleanupWHERE i<15;
91+
-- Nothing is cleaned up.
92+
VACUUM no_index_cleanup;
93+
-- Both parent relation and toast are cleaned up.
94+
ALTERTABLE no_index_cleanupSET (vacuum_index_cleanup= true);
95+
VACUUM no_index_cleanup;
96+
-- Parameter is set for both the parent table and its toast relation.
97+
INSERT INTO no_index_cleanup(i, t)VALUES (generate_series(31,60),
98+
repeat('1234567890',300));
99+
DELETEFROM no_index_cleanupWHERE i<45;
100+
-- Only toast index is cleaned up.
101+
ALTERTABLE no_index_cleanupSET (vacuum_index_cleanup= false,
102+
toast.vacuum_index_cleanup= true);
103+
VACUUM no_index_cleanup;
104+
-- Only parent is cleaned up.
105+
ALTERTABLE no_index_cleanupSET (vacuum_index_cleanup= true,
106+
toast.vacuum_index_cleanup= false);
107+
VACUUM no_index_cleanup;
108+
-- Test some extra relations.
109+
VACUUM (INDEX_CLEANUP FALSE) vaccluster;
110+
VACUUM (INDEX_CLEANUP FALSE) vactst;-- index cleanup option is ignored if no indexes
111+
VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster;
86112

87113
-- TRUNCATE option
88114
CREATETABLEvac_truncate_test(iINTNOT NULL, jtext)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp