From 1d840bc6f58faee2f4a2825fe1b595f792ca59b1 Mon Sep 17 00:00:00 2001 From: Konstantin Timoshenko Date: Fri, 14 May 2021 10:08:20 +0300 Subject: [PATCH 1/2] exclude specific table and its inheritors --- bin/pg_repack.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 38d40e22..3d335e40 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -242,6 +242,7 @@ static bool alldb = false; static bool noorder = false; static SimpleStringList parent_table_list = {NULL, NULL}; static SimpleStringList table_list = {NULL, NULL}; +static SimpleStringList exclude_table_list = {NULL, NULL}; static SimpleStringList schema_list = {NULL, NULL}; static char *orderby = NULL; static char *tablespace = NULL; @@ -284,6 +285,7 @@ static pgut_option options[] = { 'b', 'D', "no-kill-backend", &no_kill_backend }, { 'b', 'k', "no-superuser-check", &no_superuser_check }, { 'l', 'C', "exclude-extension", &exclude_extension_list }, + { 'l', 'q', "exclude-table", &exclude_table_list }, { 0 }, }; @@ -1133,6 +1135,15 @@ repack_one_table(repack_table *table, const char *orderby) bool table_init = false; initStringInfo(&sql); + /* Skip table if user ignore it */ + for (SimpleStringListCell* cell = exclude_table_list.head; cell; cell = cell->next) + { + if ( strcmp(cell->val, table->target_name) == 0 ) + { + elog(INFO, "skipping table \"%s\"", table->target_name); + return; + } + } elog(INFO, "repacking table \"%s\"", table->target_name); @@ -2222,6 +2233,7 @@ pgut_help(bool details) printf(" -a, --all repack all databases\n"); printf(" -t, --table=TABLE repack specific table only\n"); printf(" -I, --parent-table=TABLE repack specific parent table and its inheritors\n"); + printf(" -q, --exclude-table=TABLE repack exclude specific table and its inheritors\n"); printf(" -c, --schema=SCHEMA repack tables in specific schema only\n"); printf(" -s, --tablespace=TBLSPC move repacked tables to a new tablespace\n"); printf(" -S, --moveidx move repacked indexes to TBLSPC too\n"); From 63c389004e0a0457a8eab29bd2c2019f33c35b54 Mon Sep 17 00:00:00 2001 From: Konstantin Timoshenko Date: Fri, 14 May 2021 10:13:07 +0300 Subject: [PATCH 2/2] sleep for n seconds between tables --- bin/pg_repack.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 3d335e40..504c9d87 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -256,6 +256,7 @@ static unsigned int temp_obj_num = 0; /* temporary objects counter */ static bool no_kill_backend = false; /* abandon when timed-out */ static bool no_superuser_check = false; static SimpleStringList exclude_extension_list = {NULL, NULL}; /* don't repack tables of these extensions */ +static int throttle_time = 0; /* in seconds */ /* buffer should have at least 11 bytes */ static char * @@ -286,6 +287,7 @@ static pgut_option options[] = { 'b', 'k', "no-superuser-check", &no_superuser_check }, { 'l', 'C', "exclude-extension", &exclude_extension_list }, { 'l', 'q', "exclude-table", &exclude_table_list }, + { 'i', 'r', "throttling", &throttle_time }, { 0 }, }; @@ -1563,6 +1565,13 @@ repack_one_table(repack_table *table, const char *orderby) */ if ((!ret) && table_init) repack_cleanup(false, table); + + if (throttle_time > 0) + { + elog(INFO, "sleep for %d seconds", throttle_time); + sleep(throttle_time); + } + } /* Kill off any concurrent DDL (or any transaction attempting to take @@ -2248,4 +2257,5 @@ pgut_help(bool details) printf(" -Z, --no-analyze don't analyze at end\n"); printf(" -k, --no-superuser-check skip superuser checks in client\n"); printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n"); + printf(" -r, --throttling= sleep for n seconds between tables\n"); }