I applied this patch some hours ago but I haven't gotten the pgsql-committers mail and I don't see it in the archives either. Here is the evidence:
http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/config.sgml Is there a problem with pgsql-committers again? Attached is the patch I applied. $ cvs commit -F msg ? msg ? cscope.out ? cscope.files Checking in doc/src/sgml/config.sgml; /cvsroot/pgsql/doc/src/sgml/config.sgml,v <-- config.sgml new revision: 1.121; previous revision: 1.120 done Checking in src/backend/commands/analyze.c; /cvsroot/pgsql/src/backend/commands/analyze.c,v <-- analyze.c new revision: 1.105; previous revision: 1.104 done Checking in src/backend/commands/vacuumlazy.c; /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v <-- vacuumlazy.c new revision: 1.86; previous revision: 1.85 done Checking in src/backend/postmaster/autovacuum.c; /cvsroot/pgsql/src/backend/postmaster/autovacuum.c,v <-- autovacuum.c new revision: 1.42; previous revision: 1.41 done Checking in src/backend/utils/misc/guc.c; /cvsroot/pgsql/src/backend/utils/misc/guc.c,v <-- guc.c new revision: 1.386; previous revision: 1.385 done Checking in src/backend/utils/misc/postgresql.conf.sample; /cvsroot/pgsql/src/backend/utils/misc/postgresql.conf.sample,v <-- postgresql.conf.sample new revision: 1.215; previous revision: 1.214 done Checking in src/include/postmaster/autovacuum.h; /cvsroot/pgsql/src/include/postmaster/autovacuum.h,v <-- autovacuum.h new revision: 1.10; previous revision: 1.9 done Collecting file lists...Done. Sending mail to [EMAIL PROTECTED] -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.
Index: doc/src/sgml/config.sgml =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/doc/src/sgml/config.sgml,v retrieving revision 1.120 diff -c -p -r1.120 config.sgml *** doc/src/sgml/config.sgml 16 Apr 2007 18:29:50 -0000 1.120 --- doc/src/sgml/config.sgml 18 Apr 2007 15:54:53 -0000 *************** SELECT * FROM parent WHERE key = 2400; *** 3190,3195 **** --- 3190,3214 ---- </listitem> </varlistentry> + <varlistentry id="guc-log-autovacuum" xreflabel="log_autovacuum"> + <term><varname>log_autovacuum</varname> (<type>integer</type>)</term> + <indexterm> + <primary><varname>log_autovacuum</> configuration parameter</primary> + </indexterm> + <listitem> + <para> + Causes actions executed by autovacuum to be logged if it ran for at + least the specified number of milliseconds. Setting this to zero prints + all action durations. Minus-one (the default) disables logging + autovacuum action durations. For example, if you set it to + <literal>250ms</literal> then all vacuums and analyzes that run + 250ms or longer will be logged. Enabling this parameter can be helpful + in tracking autovacuum activity. This setting can only be set in + the <filename>postgresql.conf</> file or on the server command line. + </para> + </listitem> + </varlistentry> + <varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime"> <term><varname>autovacuum_naptime</varname> (<type>integer</type>)</term> <indexterm> Index: src/backend/commands/analyze.c =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/commands/analyze.c,v retrieving revision 1.104 diff -c -p -r1.104 analyze.c *** src/backend/commands/analyze.c 6 Apr 2007 04:21:42 -0000 1.104 --- src/backend/commands/analyze.c 18 Apr 2007 15:54:53 -0000 *************** *** 22,27 **** --- 22,28 ---- #include "catalog/index.h" #include "catalog/indexing.h" #include "catalog/namespace.h" + #include "commands/dbcommands.h" #include "commands/vacuum.h" #include "executor/executor.h" #include "miscadmin.h" *************** *** 29,38 **** --- 30,41 ---- #include "parser/parse_oper.h" #include "parser/parse_relation.h" #include "pgstat.h" + #include "postmaster/autovacuum.h" #include "utils/acl.h" #include "utils/datum.h" #include "utils/lsyscache.h" #include "utils/memutils.h" + #include "utils/pg_rusage.h" #include "utils/syscache.h" #include "utils/tuplesort.h" *************** analyze_rel(Oid relid, VacuumStmt *vacst *** 109,114 **** --- 112,119 ---- double totalrows, totaldeadrows; HeapTuple *rows; + PGRUsage ru0; + TimestampTz starttime = 0; if (vacstmt->verbose) elevel = INFO; *************** analyze_rel(Oid relid, VacuumStmt *vacst *** 190,195 **** --- 195,208 ---- return; } + /* measure elapsed time iff autovacuum logging requires it */ + if (IsAutoVacuumWorkerProcess() && Log_autovacuum >= 0) + { + pg_rusage_init(&ru0); + if (Log_autovacuum > 0) + starttime = GetCurrentTimestamp(); + } + ereport(elevel, (errmsg("analyzing \"%s.%s\"", get_namespace_name(RelationGetNamespace(onerel)), *************** analyze_rel(Oid relid, VacuumStmt *vacst *** 451,456 **** --- 464,497 ---- * expose us to concurrent-update failures in update_attstats.) */ relation_close(onerel, NoLock); + + /* Log the action if appropriate */ + if (IsAutoVacuumWorkerProcess() && Log_autovacuum >= 0) + { + long diff; + + if (Log_autovacuum > 0) + { + TimestampTz endtime; + int usecs; + long secs; + + endtime = GetCurrentTimestamp(); + TimestampDifference(starttime, endtime, &secs, &usecs); + + diff = secs * 1000 + usecs / 1000; + } + + if (Log_autovacuum == 0 || diff >= Log_autovacuum) + { + ereport(LOG, + (errmsg("automatic analyze of table \"%s.%s.%s\" system usage: %s", + get_database_name(MyDatabaseId), + get_namespace_name(RelationGetNamespace(onerel)), + RelationGetRelationName(onerel), + pg_rusage_show(&ru0)))); + } + } } /* Index: src/backend/commands/vacuumlazy.c =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/commands/vacuumlazy.c,v retrieving revision 1.85 diff -c -p -r1.85 vacuumlazy.c *** src/backend/commands/vacuumlazy.c 21 Feb 2007 22:47:45 -0000 1.85 --- src/backend/commands/vacuumlazy.c 18 Apr 2007 15:54:53 -0000 *************** *** 47,55 **** --- 47,57 ---- #include "access/genam.h" #include "access/heapam.h" #include "access/transam.h" + #include "commands/dbcommands.h" #include "commands/vacuum.h" #include "miscadmin.h" #include "pgstat.h" + #include "postmaster/autovacuum.h" #include "storage/freespace.h" #include "utils/lsyscache.h" #include "utils/memutils.h" *************** typedef struct LVRelStats *** 90,95 **** --- 92,98 ---- int max_free_pages; /* # slots allocated in array */ PageFreeSpaceInfo *free_pages; /* array or heap of blkno/avail */ BlockNumber tot_free_pages; /* total pages with >= threshold space */ + int num_index_scans; } LVRelStats; *************** lazy_vacuum_rel(Relation onerel, VacuumS *** 141,146 **** --- 144,157 ---- Relation *Irel; int nindexes; BlockNumber possibly_freeable; + PGRUsage ru0; + TimestampTz starttime = 0; + + pg_rusage_init(&ru0); + + /* measure elapsed time iff autovacuum logging requires it */ + if (IsAutoVacuumWorkerProcess() && Log_autovacuum > 0) + starttime = GetCurrentTimestamp(); if (vacstmt->verbose) elevel = INFO; *************** lazy_vacuum_rel(Relation onerel, VacuumS *** 156,161 **** --- 167,174 ---- /* XXX should we scale it up or down? Adjust vacuum.c too, if so */ vacrelstats->threshold = GetAvgFSMRequestSize(&onerel->rd_node); + vacrelstats->num_index_scans = 0; + /* Open all indexes of the relation */ vac_open_indexes(onerel, RowExclusiveLock, &nindexes, &Irel); vacrelstats->hasindex = (nindexes > 0); *************** lazy_vacuum_rel(Relation onerel, VacuumS *** 200,205 **** --- 213,252 ---- /* report results to the stats collector, too */ pgstat_report_vacuum(RelationGetRelid(onerel), onerel->rd_rel->relisshared, vacstmt->analyze, vacrelstats->rel_tuples); + + /* and log the action if appropriate */ + if (IsAutoVacuumWorkerProcess() && Log_autovacuum >= 0) + { + long diff; + + if (Log_autovacuum > 0) + { + TimestampTz endtime; + int usecs; + long secs; + + endtime = GetCurrentTimestamp(); + TimestampDifference(starttime, endtime, &secs, &usecs); + + diff = secs * 1000 + usecs / 1000; + } + + if (Log_autovacuum == 0 || diff >= Log_autovacuum) + { + ereport(LOG, + (errmsg("automatic vacuum of table \"%s.%s.%s\": index scans: %d\n" + "pages: %d removed, %d remain\n" + "tuples: %.0f removed, %.0f remain\n" + "system usage: %s", + get_database_name(MyDatabaseId), + get_namespace_name(RelationGetNamespace(onerel)), + RelationGetRelationName(onerel), + vacrelstats->num_index_scans, + vacrelstats->pages_removed, vacrelstats->rel_pages, + vacrelstats->tuples_deleted, vacrelstats->rel_tuples, + pg_rusage_show(&ru0)))); + } + } } *************** lazy_scan_heap(Relation onerel, LVRelSta *** 282,287 **** --- 329,335 ---- lazy_vacuum_heap(onerel, vacrelstats); /* Forget the now-vacuumed tuples, and press on */ vacrelstats->num_dead_tuples = 0; + vacrelstats->num_index_scans++; } buf = ReadBuffer(onerel, blkno); *************** lazy_scan_heap(Relation onerel, LVRelSta *** 490,495 **** --- 538,544 ---- vacrelstats); /* Remove tuples from heap */ lazy_vacuum_heap(onerel, vacrelstats); + vacrelstats->num_index_scans++; } /* Do post-vacuum cleanup and statistics update for each index */ Index: src/backend/postmaster/autovacuum.c =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/autovacuum.c,v retrieving revision 1.41 diff -c -p -r1.41 autovacuum.c *** src/backend/postmaster/autovacuum.c 16 Apr 2007 18:29:52 -0000 1.41 --- src/backend/postmaster/autovacuum.c 18 Apr 2007 15:54:53 -0000 *************** int autovacuum_freeze_max_age; *** 71,76 **** --- 71,78 ---- int autovacuum_vac_cost_delay; int autovacuum_vac_cost_limit; + int Log_autovacuum = -1; + /* Flags to tell if we are in an autovacuum process */ static bool am_autovacuum_launcher = false; static bool am_autovacuum_worker = false; *************** do_autovacuum(void) *** 1814,1820 **** { Oid relid = lfirst_oid(cell); autovac_table *tab; - char *relname; WorkerInfo worker; bool skipit; --- 1816,1821 ---- *************** next_worker: *** 1891,1902 **** VacuumCostDelay = tab->at_vacuum_cost_delay; VacuumCostLimit = tab->at_vacuum_cost_limit; - relname = get_rel_name(relid); - elog(DEBUG2, "autovac: will%s%s %s", - (tab->at_dovacuum ? " VACUUM" : ""), - (tab->at_doanalyze ? " ANALYZE" : ""), - relname); - /* * Advertise my cost delay parameters for the balancing algorithm, and * do a balance --- 1892,1897 ---- *************** next_worker: *** 1915,1921 **** tab->at_freeze_min_age); /* be tidy */ pfree(tab); - pfree(relname); } /* --- 1910,1915 ---- Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/misc/guc.c,v retrieving revision 1.385 diff -c -p -r1.385 guc.c *** src/backend/utils/misc/guc.c 16 Apr 2007 18:29:55 -0000 1.385 --- src/backend/utils/misc/guc.c 18 Apr 2007 15:54:53 -0000 *************** static struct config_int ConfigureNamesI *** 1506,1511 **** --- 1506,1522 ---- }, { + {"log_autovacuum", PGC_BACKEND, LOGGING_WHAT, + gettext_noop("Sets the minimum execution time above which autovacuum actions " + "will be logged."), + gettext_noop("Zero prints all actions. The default is -1 (turning this feature off)."), + GUC_UNIT_MS + }, + &Log_autovacuum, + -1, -1, INT_MAX / 1000, NULL, NULL + }, + + { {"bgwriter_delay", PGC_SIGHUP, RESOURCES, gettext_noop("Background writer sleep time between rounds."), NULL, Index: src/backend/utils/misc/postgresql.conf.sample =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/misc/postgresql.conf.sample,v retrieving revision 1.214 diff -c -p -r1.214 postgresql.conf.sample *** src/backend/utils/misc/postgresql.conf.sample 16 Apr 2007 18:29:55 -0000 1.214 --- src/backend/utils/misc/postgresql.conf.sample 18 Apr 2007 15:54:53 -0000 *************** *** 376,383 **** #autovacuum = on # enable autovacuum subprocess? # 'on' requires stats_start_collector # and stats_row_level to also be on ! #autovacuum_max_workers = 3 # max # of autovacuum subprocesses #autovacuum_naptime = 1min # time between autovacuum runs #autovacuum_vacuum_threshold = 500 # min # of tuple updates before # vacuum #autovacuum_analyze_threshold = 250 # min # of tuple updates before --- 376,386 ---- #autovacuum = on # enable autovacuum subprocess? # 'on' requires stats_start_collector # and stats_row_level to also be on ! #autovacuum_max_workers = 3 # max # of autovacuum subprocesses #autovacuum_naptime = 1min # time between autovacuum runs + #log_autovacuum = -1 # -1 is disabled, 0 logs all actions + # and their durations, > 0 logs only + # actions running at least N msec. #autovacuum_vacuum_threshold = 500 # min # of tuple updates before # vacuum #autovacuum_analyze_threshold = 250 # min # of tuple updates before Index: src/include/postmaster/autovacuum.h =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/include/postmaster/autovacuum.h,v retrieving revision 1.9 diff -c -p -r1.9 autovacuum.h *** src/include/postmaster/autovacuum.h 16 Apr 2007 18:30:03 -0000 1.9 --- src/include/postmaster/autovacuum.h 18 Apr 2007 15:54:53 -0000 *************** extern int autovacuum_vac_cost_limit; *** 31,36 **** --- 31,38 ---- /* autovacuum launcher PID, only valid when worker is shutting down */ extern int AutovacuumLauncherPid; + extern int Log_autovacuum; + /* Status inquiry functions */ extern bool AutoVacuumingActive(void); extern bool IsAutoVacuumLauncherProcess(void);
---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq