mirror of https://github.com/citusdata/citus.git
Merge pull request #6033 from citusdata/vacuum-index-cleanup-auto
auto is a valid option for vacuum index_cleanup.pull/6044/head
commit
4e9ea834b6
|
@ -380,10 +380,33 @@ DeparseVacuumStmtPrefix(CitusVacuumParams vacuumParams)
|
|||
|
||||
if (vacuumParams.index_cleanup != VACOPTVALUE_UNSPECIFIED)
|
||||
{
|
||||
appendStringInfoString(vacuumPrefix,
|
||||
vacuumParams.index_cleanup == VACOPTVALUE_ENABLED ?
|
||||
"INDEX_CLEANUP," : "INDEX_CLEANUP false,"
|
||||
);
|
||||
switch (vacuumParams.index_cleanup)
|
||||
{
|
||||
case VACOPTVALUE_ENABLED:
|
||||
{
|
||||
appendStringInfoString(vacuumPrefix, "INDEX_CLEANUP true,");
|
||||
break;
|
||||
}
|
||||
|
||||
case VACOPTVALUE_DISABLED:
|
||||
{
|
||||
appendStringInfoString(vacuumPrefix, "INDEX_CLEANUP false,");
|
||||
break;
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
case VACOPTVALUE_AUTO:
|
||||
{
|
||||
appendStringInfoString(vacuumPrefix, "INDEX_CLEANUP auto,");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||
|
@ -541,8 +564,32 @@ VacuumStmtParams(VacuumStmt *vacstmt)
|
|||
#endif
|
||||
else if (strcmp(opt->defname, "index_cleanup") == 0)
|
||||
{
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
|
||||
/* Interpret no string as the default, which is 'auto' */
|
||||
if (!opt->arg)
|
||||
{
|
||||
params.index_cleanup = VACOPTVALUE_AUTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *sval = defGetString(opt);
|
||||
|
||||
/* Try matching on 'auto' string, or fall back on boolean */
|
||||
if (pg_strcasecmp(sval, "auto") == 0)
|
||||
{
|
||||
params.index_cleanup = VACOPTVALUE_AUTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.index_cleanup = defGetBoolean(opt) ? VACOPTVALUE_ENABLED :
|
||||
VACOPTVALUE_DISABLED;
|
||||
}
|
||||
}
|
||||
#else
|
||||
params.index_cleanup = defGetBoolean(opt) ? VACOPTVALUE_ENABLED :
|
||||
VACOPTVALUE_DISABLED;
|
||||
#endif
|
||||
}
|
||||
else if (strcmp(opt->defname, "truncate") == 0)
|
||||
{
|
||||
|
|
|
@ -404,21 +404,6 @@ SELECT pg_size_pretty( pg_total_relation_size('local_vacuum_table') );
|
|||
21 MB
|
||||
(1 row)
|
||||
|
||||
----------------- PROCESS_TOAST is only available for pg14
|
||||
-- vacuum (process_toast false) should not be vacuuming toast tables (default is true)
|
||||
--select reltoastrelid from pg_class where relname='local_vacuum_table'
|
||||
--\gset
|
||||
--SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
--\gset
|
||||
--VACUUM (FREEZE, PROCESS_TOAST true) local_vacuum_table;
|
||||
--SELECT relfrozenxid::text::integer > :frozenxid AS frozen_performed FROM pg_class
|
||||
--WHERE oid=:reltoastrelid::regclass;
|
||||
--SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
--\gset
|
||||
--VACUUM (FREEZE, PROCESS_TOAST false) local_vacuum_table;
|
||||
--SELECT relfrozenxid::text::integer = :frozenxid AS frozen_not_performed FROM pg_class
|
||||
--WHERE oid=:reltoastrelid::regclass;
|
||||
---------------------------------------------------------------------
|
||||
-- vacuum (truncate false) should not attempt to truncate off any empty pages at the end of the table (default is true)
|
||||
insert into local_vacuum_table select i from generate_series(1,1000000) i;
|
||||
delete from local_vacuum_table;
|
||||
|
|
|
@ -10,7 +10,7 @@ set search_path to pg14;
|
|||
SET citus.shard_replication_factor TO 1;
|
||||
SET citus.next_shard_id TO 980000;
|
||||
SET citus.shard_count TO 2;
|
||||
-- test the new vacuum option, process_toast
|
||||
-- test the new vacuum option, process_toast and also auto option for index_cleanup
|
||||
CREATE TABLE t1 (a int);
|
||||
SELECT create_distributed_table('t1','a');
|
||||
create_distributed_table
|
||||
|
@ -41,6 +41,69 @@ NOTICE: issuing VACUUM pg14.t1_980000
|
|||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (INDEX_CLEANUP AUTO) t1;
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP auto) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP auto) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (INDEX_CLEANUP) t1;
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP auto) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP auto) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (INDEX_CLEANUP AuTo) t1;
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP auto) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP auto) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (INDEX_CLEANUP false) t1;
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP false) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP false) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (INDEX_CLEANUP true) t1;
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP true) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (INDEX_CLEANUP true) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (INDEX_CLEANUP "AUTOX") t1;
|
||||
ERROR: index_cleanup requires a Boolean value
|
||||
VACUUM (FULL, FREEZE, VERBOSE false, ANALYZE, SKIP_LOCKED, INDEX_CLEANUP, PROCESS_TOAST, TRUNCATE) t1;
|
||||
NOTICE: issuing VACUUM (ANALYZE,FREEZE,FULL,SKIP_LOCKED,PROCESS_TOAST,TRUNCATE,INDEX_CLEANUP auto) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (ANALYZE,FREEZE,FULL,SKIP_LOCKED,PROCESS_TOAST,TRUNCATE,INDEX_CLEANUP auto) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
VACUUM (FULL, FREEZE false, VERBOSE false, ANALYZE false, SKIP_LOCKED false, INDEX_CLEANUP "Auto", PROCESS_TOAST true, TRUNCATE false) t1;
|
||||
NOTICE: issuing VACUUM (FULL,PROCESS_TOAST,TRUNCATE false,INDEX_CLEANUP auto) pg14.t1_980000
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing VACUUM (FULL,PROCESS_TOAST,TRUNCATE false,INDEX_CLEANUP auto) pg14.t1_980001
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
-- vacuum (process_toast true) should be vacuuming toast tables (default is true)
|
||||
CREATE TABLE local_vacuum_table(name text);
|
||||
select reltoastrelid from pg_class where relname='local_vacuum_table'
|
||||
\gset
|
||||
SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
\gset
|
||||
VACUUM (FREEZE, PROCESS_TOAST true) local_vacuum_table;
|
||||
SELECT relfrozenxid::text::integer > :frozenxid AS frozen_performed FROM pg_class
|
||||
WHERE oid=:reltoastrelid::regclass;
|
||||
frozen_performed
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- vacuum (process_toast false) should not be vacuuming toast tables (default is true)
|
||||
SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
\gset
|
||||
VACUUM (FREEZE, PROCESS_TOAST false) local_vacuum_table;
|
||||
SELECT relfrozenxid::text::integer = :frozenxid AS frozen_not_performed FROM pg_class
|
||||
WHERE oid=:reltoastrelid::regclass;
|
||||
frozen_not_performed
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
DROP TABLE local_vacuum_table;
|
||||
SET citus.log_remote_commands TO OFF;
|
||||
create table dist(a int, b int);
|
||||
select create_distributed_table('dist','a');
|
||||
|
|
|
@ -252,24 +252,6 @@ delete from local_vacuum_table;
|
|||
VACUUM (INDEX_CLEANUP ON, PARALLEL 1) local_vacuum_table;
|
||||
SELECT pg_size_pretty( pg_total_relation_size('local_vacuum_table') );
|
||||
|
||||
----------------- PROCESS_TOAST is only available for pg14
|
||||
-- vacuum (process_toast false) should not be vacuuming toast tables (default is true)
|
||||
--select reltoastrelid from pg_class where relname='local_vacuum_table'
|
||||
--\gset
|
||||
|
||||
--SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
--\gset
|
||||
--VACUUM (FREEZE, PROCESS_TOAST true) local_vacuum_table;
|
||||
--SELECT relfrozenxid::text::integer > :frozenxid AS frozen_performed FROM pg_class
|
||||
--WHERE oid=:reltoastrelid::regclass;
|
||||
|
||||
--SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
--\gset
|
||||
--VACUUM (FREEZE, PROCESS_TOAST false) local_vacuum_table;
|
||||
--SELECT relfrozenxid::text::integer = :frozenxid AS frozen_not_performed FROM pg_class
|
||||
--WHERE oid=:reltoastrelid::regclass;
|
||||
---------------
|
||||
|
||||
-- vacuum (truncate false) should not attempt to truncate off any empty pages at the end of the table (default is true)
|
||||
insert into local_vacuum_table select i from generate_series(1,1000000) i;
|
||||
delete from local_vacuum_table;
|
||||
|
|
|
@ -12,7 +12,7 @@ SET citus.shard_replication_factor TO 1;
|
|||
SET citus.next_shard_id TO 980000;
|
||||
SET citus.shard_count TO 2;
|
||||
|
||||
-- test the new vacuum option, process_toast
|
||||
-- test the new vacuum option, process_toast and also auto option for index_cleanup
|
||||
CREATE TABLE t1 (a int);
|
||||
SELECT create_distributed_table('t1','a');
|
||||
SET citus.log_remote_commands TO ON;
|
||||
|
@ -21,6 +21,34 @@ VACUUM (FULL, PROCESS_TOAST) t1;
|
|||
VACUUM (FULL, PROCESS_TOAST true) t1;
|
||||
VACUUM (FULL, PROCESS_TOAST false) t1;
|
||||
VACUUM (PROCESS_TOAST false) t1;
|
||||
VACUUM (INDEX_CLEANUP AUTO) t1;
|
||||
VACUUM (INDEX_CLEANUP) t1;
|
||||
VACUUM (INDEX_CLEANUP AuTo) t1;
|
||||
VACUUM (INDEX_CLEANUP false) t1;
|
||||
VACUUM (INDEX_CLEANUP true) t1;
|
||||
VACUUM (INDEX_CLEANUP "AUTOX") t1;
|
||||
VACUUM (FULL, FREEZE, VERBOSE false, ANALYZE, SKIP_LOCKED, INDEX_CLEANUP, PROCESS_TOAST, TRUNCATE) t1;
|
||||
VACUUM (FULL, FREEZE false, VERBOSE false, ANALYZE false, SKIP_LOCKED false, INDEX_CLEANUP "Auto", PROCESS_TOAST true, TRUNCATE false) t1;
|
||||
|
||||
-- vacuum (process_toast true) should be vacuuming toast tables (default is true)
|
||||
CREATE TABLE local_vacuum_table(name text);
|
||||
select reltoastrelid from pg_class where relname='local_vacuum_table'
|
||||
\gset
|
||||
|
||||
SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
\gset
|
||||
VACUUM (FREEZE, PROCESS_TOAST true) local_vacuum_table;
|
||||
SELECT relfrozenxid::text::integer > :frozenxid AS frozen_performed FROM pg_class
|
||||
WHERE oid=:reltoastrelid::regclass;
|
||||
|
||||
-- vacuum (process_toast false) should not be vacuuming toast tables (default is true)
|
||||
SELECT relfrozenxid AS frozenxid FROM pg_class WHERE oid=:reltoastrelid::regclass
|
||||
\gset
|
||||
VACUUM (FREEZE, PROCESS_TOAST false) local_vacuum_table;
|
||||
SELECT relfrozenxid::text::integer = :frozenxid AS frozen_not_performed FROM pg_class
|
||||
WHERE oid=:reltoastrelid::regclass;
|
||||
|
||||
DROP TABLE local_vacuum_table;
|
||||
SET citus.log_remote_commands TO OFF;
|
||||
|
||||
create table dist(a int, b int);
|
||||
|
|
Loading…
Reference in New Issue