mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-03 00:46:56 +02:00
The following patch should allow UPDATE_INTERVAL to be specified on the
command line. We find this useful because we frequently deal with thousands of tables in an environment where neither the databases nor the tables are updated frequently. This helps allow us to cut down on the overhead of updating the list for every other primary loop of pg_autovacuum. I chose -i as the command-line argument and documented it briefly in the README. The patch was applied to the 7.4.7 version of pg_autovacuum in contrib. Thomas F.O'Connell
This commit is contained in:
parent
aa8bdab272
commit
7cce39c7ce
@ -123,6 +123,10 @@ pg_autovacuum has the following optional arguments:
|
|||||||
-V vacuum scaling factor: see "Vacuum and Analyze" below.
|
-V vacuum scaling factor: see "Vacuum and Analyze" below.
|
||||||
-a analyze base threshold: see "Vacuum and Analyze" below.
|
-a analyze base threshold: see "Vacuum and Analyze" below.
|
||||||
-A analyze scaling factor: see "Vacuum and Analyze" below.
|
-A analyze scaling factor: see "Vacuum and Analyze" below.
|
||||||
|
-i update interval: how often (in terms of iterations of the primary loop
|
||||||
|
over the database list) to update the database list. The default is 2,
|
||||||
|
which means the list will be updated before every other pass through
|
||||||
|
the database list.
|
||||||
-L log file: Name of file to which output is submitted, otherwise STDERR
|
-L log file: Name of file to which output is submitted, otherwise STDERR
|
||||||
-U username: Username pg_autovacuum will use to connect with, if not
|
-U username: Username pg_autovacuum will use to connect with, if not
|
||||||
specified the current username is used.
|
specified the current username is used.
|
||||||
@ -157,6 +161,7 @@ the time of writing they are:
|
|||||||
-A 1 (half of -V if not specified)
|
-A 1 (half of -V if not specified)
|
||||||
-s 300 (5 minutes)
|
-s 300 (5 minutes)
|
||||||
-S 2
|
-S 2
|
||||||
|
-i 2
|
||||||
|
|
||||||
The following arguments are used on Windows only:
|
The following arguments are used on Windows only:
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Revisions by Christopher B. Browne, Liberty RMS
|
* Revisions by Christopher B. Browne, Liberty RMS
|
||||||
* Win32 Service code added by Dave Page
|
* Win32 Service code added by Dave Page
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.30 2005/04/03 00:01:51 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.31 2005/04/19 03:35:15 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -1103,6 +1103,7 @@ get_cmd_args(int argc, char *argv[])
|
|||||||
args->analyze_base_threshold = -1;
|
args->analyze_base_threshold = -1;
|
||||||
args->analyze_scaling_factor = -1;
|
args->analyze_scaling_factor = -1;
|
||||||
args->debug = AUTOVACUUM_DEBUG;
|
args->debug = AUTOVACUUM_DEBUG;
|
||||||
|
args->update_interval = UPDATE_INTERVAL;
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
args->daemonize = 0;
|
args->daemonize = 0;
|
||||||
#else
|
#else
|
||||||
@ -1157,6 +1158,9 @@ get_cmd_args(int argc, char *argv[])
|
|||||||
case 'A':
|
case 'A':
|
||||||
args->analyze_scaling_factor = atof(optarg);
|
args->analyze_scaling_factor = atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
args->update_interval = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
args->av_vacuum_cost_delay = atoi(optarg);
|
args->av_vacuum_cost_delay = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
@ -1341,6 +1345,8 @@ print_cmd_args(void)
|
|||||||
log_entry(logbuffer, LVL_INFO);
|
log_entry(logbuffer, LVL_INFO);
|
||||||
sprintf(logbuffer, " args->analyze_scaling_factor=%f", args->analyze_scaling_factor);
|
sprintf(logbuffer, " args->analyze_scaling_factor=%f", args->analyze_scaling_factor);
|
||||||
log_entry(logbuffer, LVL_INFO);
|
log_entry(logbuffer, LVL_INFO);
|
||||||
|
sprintf(logbuffer, " args->update_interval=%i", args->update_interval);
|
||||||
|
log_entry(logbuffer, LVL_INFO);
|
||||||
|
|
||||||
if (args->av_vacuum_cost_delay != -1)
|
if (args->av_vacuum_cost_delay != -1)
|
||||||
sprintf(logbuffer, " args->av_vacuum_cost_delay=%d", args->av_vacuum_cost_delay);
|
sprintf(logbuffer, " args->av_vacuum_cost_delay=%d", args->av_vacuum_cost_delay);
|
||||||
@ -1646,7 +1652,7 @@ VacuumLoop(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loops % UPDATE_INTERVAL == 0) /* Update the list if it's
|
if (loops % args->update_interval == 0) /* Update the list if it's
|
||||||
* time */
|
* time */
|
||||||
update_db_list(db_list); /* Add and remove databases from
|
update_db_list(db_list); /* Add and remove databases from
|
||||||
* the list */
|
* the list */
|
||||||
@ -1661,7 +1667,7 @@ VacuumLoop(int argc, char **argv)
|
|||||||
|
|
||||||
if (dbs->conn != NULL)
|
if (dbs->conn != NULL)
|
||||||
{
|
{
|
||||||
if (loops % UPDATE_INTERVAL == 0) /* Update the list if
|
if (loops % args->update_interval == 0) /* Update the list if
|
||||||
* it's time */
|
* it's time */
|
||||||
update_table_list(dbs); /* Add and remove tables
|
update_table_list(dbs); /* Add and remove tables
|
||||||
* from the list */
|
* from the list */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Header file for pg_autovacuum.c
|
* Header file for pg_autovacuum.c
|
||||||
* (c) 2003 Matthew T. O'Connor
|
* (c) 2003 Matthew T. O'Connor
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.h,v 1.14 2004/12/02 22:48:10 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.h,v 1.15 2005/04/19 03:35:15 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PG_AUTOVACUUM_H
|
#ifndef _PG_AUTOVACUUM_H
|
||||||
@ -44,6 +44,7 @@ typedef struct cmdargs
|
|||||||
{
|
{
|
||||||
int vacuum_base_threshold,
|
int vacuum_base_threshold,
|
||||||
analyze_base_threshold,
|
analyze_base_threshold,
|
||||||
|
update_interval,
|
||||||
sleep_base_value,
|
sleep_base_value,
|
||||||
debug,
|
debug,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user