]> granicus.if.org Git - postgresql/commitdiff
Add vacuum_freeze_table_age GUC option, to control when VACUUM should
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 16 Jan 2009 13:27:24 +0000 (13:27 +0000)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 16 Jan 2009 13:27:24 +0000 (13:27 +0000)
ignore the visibility map and scan the whole table, to advance
relfrozenxid.

16 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/config.sgml
doc/src/sgml/maintenance.sgml
src/backend/commands/cluster.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumlazy.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/backend/postmaster/autovacuum.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/include/catalog/catversion.h
src/include/catalog/pg_autovacuum.h
src/include/commands/vacuum.h
src/include/nodes/parsenodes.h

index ed19ea1633160f9cd55c5b9d434eefaba4c9367a..b590d0f4f79a38c80980665b4d99e22746c6cf7a 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.188 2009/01/09 15:02:22 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.189 2009/01/16 13:27:23 heikki Exp $ -->
 <!--
  Documentation of the system catalogs, directed toward PostgreSQL developers
  -->
       <entry></entry>
       <entry>Custom <varname>autovacuum_freeze_max_age</> parameter</entry>
      </row>
+
+     <row>
+      <entry><structfield>freeze_table_age</structfield></entry>
+      <entry><type>integer</type></entry>
+      <entry></entry>
+      <entry>Custom <varname>vacuum_freeze_table_age</> parameter</entry>
+     </row>
     </tbody>
    </tgroup>
   </table>
index 7d21e31bdb5143c249d8d14f28a0bfab462928d4..0b77731e3411c30a26de6fc2f7ebde1e974c7257 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.205 2009/01/12 05:10:44 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.206 2009/01/16 13:27:23 heikki Exp $ -->
 
 <chapter Id="runtime-config">
   <title>Server Configuration</title>
@@ -3950,6 +3950,27 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-vacuum-freeze-table-age" xreflabel="vacuum_freeze_table_age">
+      <term><varname>vacuum_freeze_table_age</varname> (<type>integer</type>)</term>
+      <indexterm>
+       <primary><varname>vacuum_freeze_table_age</> configuration parameter</primary>
+      </indexterm>
+      <listitem>
+       <para>
+        <command>VACUUM</> performs a whole-table scan if the table's
+        <structname>pg_class</>.<structfield>relfrozenxid</> field has reached
+        the age specified by this setting.  The default is 150 million
+        transactions.  Although users can set this value anywhere from zero to
+        one billion, <command>VACUUM</> will silently limit the effective value
+        to 95% of <xref linkend="guc-autovacuum-freeze-max-age">, so that a
+        periodical manual <command>VACUUM</> has a chance to run before an
+        anti-wraparound autovacuum is launched for the table. For more
+        information see
+        <xref linkend="vacuum-for-wraparound">.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-vacuum-freeze-min-age" xreflabel="vacuum_freeze_min_age">
       <term><varname>vacuum_freeze_min_age</varname> (<type>integer</type>)</term>
       <indexterm>
@@ -3960,7 +3981,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
         Specifies the cutoff age (in transactions) that <command>VACUUM</>
         should use to decide whether to replace transaction IDs with
         <literal>FrozenXID</> while scanning a table.
-        The default is 100 million transactions.  Although
+        The default is 50 million transactions.  Although
         users can set this value anywhere from zero to one billion,
         <command>VACUUM</> will silently limit the effective value to half
         the value of <xref linkend="guc-autovacuum-freeze-max-age">, so
index f7925a0eee73b988ddcbbf709ce6f96edbae6535..ad9c38da55b862d7271bc4bba64a21c46580f6de 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.88 2008/12/11 18:16:18 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.89 2009/01/16 13:27:23 heikki Exp $ -->
 
 <chapter id="maintenance">
  <title>Routine Database Maintenance Tasks</title>
    </para>
 
    <para>
-    <command>VACUUM</>'s behavior is controlled by the configuration parameter
-    <xref linkend="guc-vacuum-freeze-min-age">: any XID older than
-    <varname>vacuum_freeze_min_age</> transactions is replaced by
-    <literal>FrozenXID</>.  Larger values of <varname>vacuum_freeze_min_age</>
+    <command>VACUUM</>'s behavior is controlled by the two configuration
+    parameters: <xref linkend="guc-vacuum-freeze-min-age"> and
+    <xref linkend="guc-vacuum-freeze-table-age">.
+    <varname>vacuum_freeze_table_age</> controls when <command>VACUUM</>
+    performs a full sweep of the table, in order to replace old XID values 
+    with <literal>FrozenXID</>.  <varname>vacuum_freeze_min_age</> 
+    controls how old an XID value has to be before it's replaced with
+    <literal>FrozenXID</>.  Larger values of these settings
     preserve transactional information longer, while smaller values increase
     the number of transactions that can elapse before the table must be
     vacuumed again.
    <para>
     The maximum time that a table can go unvacuumed is two billion
     transactions minus the <varname>vacuum_freeze_min_age</> that was used
-    when it was last vacuumed.  If it were to go unvacuumed for longer than
+    when <command>VACUUM</> last scanned the whole table.  If it were to go
+    unvacuumed for longer than
     that, data loss could result.  To ensure that this does not happen,
     autovacuum is invoked on any table that might contain XIDs older than the
     age specified by the configuration parameter <xref
    </para>
 
    <para>
-    The sole disadvantage of increasing <varname>autovacuum_freeze_max_age</>
+    The sole disadvantage of increasing <varname>vacuum_freeze_table_age</>
+    and <varname>autovacuum_freeze_max_age</>
     is that the <filename>pg_clog</> subdirectory of the database cluster
     will take more space, because it must store the commit status for all
     transactions back to the <varname>autovacuum_freeze_max_age</> horizon.
     <varname>autovacuum_freeze_max_age</> has its maximum allowed value of
     a little less than two billion, <filename>pg_clog</> can be expected to
     grow to about half a gigabyte.  If this is trivial compared to your
-    total database size, setting <varname>autovacuum_freeze_max_age</> to
-    its maximum allowed value is recommended.  Otherwise, set it depending
+    total database size, setting <varname>autovacuum_freeze_max_age</> and
+    <varname>vacuum_freeze_table_age</varname> to their maximum allowed values
+    is recommended.  Otherwise, set them depending
     on what you are willing to allow for <filename>pg_clog</> storage.
     (The default, 200 million transactions, translates to about 50MB of
     <filename>pg_clog</> storage.)
@@ -455,13 +462,24 @@ SELECT datname, age(datfrozenxid) FROM pg_database;
 </programlisting>
 
     The <literal>age</> column measures the number of transactions from the
-    cutoff XID to the current transaction's XID.  Immediately after a
-    <command>VACUUM</>, <literal>age(relfrozenxid)</> should be a little
-    more than the <varname>vacuum_freeze_min_age</> setting that was used
-    (more by the number of transactions started since the <command>VACUUM</>
-    started).  If <literal>age(relfrozenxid)</> exceeds
-    <varname>autovacuum_freeze_max_age</>, an autovacuum will soon be forced
-    for the table.
+    cutoff XID to the current transaction's XID.  When <command>VACUUM</>
+    scans the whole table, after it's finished <literal>age(relfrozenxid)</>
+    should be a little more than the <varname>vacuum_freeze_min_age</> setting
+    that was used (more by the number of transactions started since the
+    <command>VACUUM</> started).
+   </para>
+
+   <para>
+    <command>VACUUM</> normally only scans pages that have been modified
+    since last vacuum, but <structfield>relfrozenxid</> can only be advanced
+    when the whole table is scanned. The whole table is scanned when
+    <structfield>relfrozenxid</> is more than
+    <varname>vacuum_freeze_table_age</> transactions old, if
+    <command>VACUUM FREEZE</> command is used, or if all pages happen to
+    require vacuuming to remove dead row versions. If no whole-table-scanning
+    <command>VACUUM</> is issued on the table until
+    <varname>autovacuum_freeze_max_age</> is reached, an autovacuum will soon
+    be forced for the table.
    </para>
 
    <para>
index 3e54d49dec5af6870e580b28c536676c46a9f4b2..e5bff5cb3ef205c00225e9697aada61894c65a40 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.180 2009/01/01 17:23:37 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.181 2009/01/16 13:27:23 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -789,8 +789,8 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
         * freeze_min_age to avoid having CLUSTER freeze tuples earlier than a
         * plain VACUUM would.
         */
-       vacuum_set_xid_limits(-1, OldHeap->rd_rel->relisshared,
-                                                 &OldestXmin, &FreezeXid);
+       vacuum_set_xid_limits(-1, -1, OldHeap->rd_rel->relisshared,
+                                                 &OldestXmin, &FreezeXid, NULL);
 
        /*
         * FreezeXid will become the table's new relfrozenxid, and that mustn't
index 755eec11e02e04a3fff6bafd7a4269d83cf92976..4020bf1b29448cc58290fc844de7352f8daa5aef 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.384 2009/01/01 17:23:40 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.385 2009/01/16 13:27:23 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -62,6 +62,7 @@
  * GUC parameters
  */
 int                    vacuum_freeze_min_age;
+int                    vacuum_freeze_table_age;
 
 /*
  * VacPage structures keep track of each page on which we find useful
@@ -590,9 +591,12 @@ get_rel_oids(Oid relid, const RangeVar *vacrel, const char *stmttype)
  * vacuum_set_xid_limits() -- compute oldest-Xmin and freeze cutoff points
  */
 void
-vacuum_set_xid_limits(int freeze_min_age, bool sharedRel,
+vacuum_set_xid_limits(int freeze_min_age,
+                                         int freeze_table_age,
+                                         bool sharedRel,
                                          TransactionId *oldestXmin,
-                                         TransactionId *freezeLimit)
+                                         TransactionId *freezeLimit,
+                                         TransactionId *freezeTableLimit)
 {
        int                     freezemin;
        TransactionId limit;
@@ -648,6 +652,34 @@ vacuum_set_xid_limits(int freeze_min_age, bool sharedRel,
        }
 
        *freezeLimit = limit;
+
+       if (freezeTableLimit != NULL)
+       {
+               int freezetable;
+
+               /*
+                * Determine the table freeze age to use: as specified by the caller,
+                * or vacuum_freeze_table_age, but in any case not more than
+                * autovacuum_freeze_max_age * 0.95, so that if you have e.g nightly
+                * VACUUM schedule, the nightly VACUUM gets a chance to freeze tuples
+                * before anti-wraparound autovacuum is launched.
+                */
+               freezetable = freeze_min_age;
+               if (freezetable < 0)
+                       freezetable = vacuum_freeze_table_age;
+               freezetable = Min(freezetable, autovacuum_freeze_max_age * 0.95);
+               Assert(freezetable >= 0);
+
+               /*
+                * Compute the cutoff XID, being careful not to generate a
+                * "permanent" XID.
+                */
+               limit = ReadNewTransactionId() - freezetable;
+               if (!TransactionIdIsNormal(limit))
+                       limit = FirstNormalTransactionId;
+
+               *freezeTableLimit = limit;
+       }
 }
 
 
@@ -1219,8 +1251,9 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
                                i;
        VRelStats  *vacrelstats;
 
-       vacuum_set_xid_limits(vacstmt->freeze_min_age, onerel->rd_rel->relisshared,
-                                                 &OldestXmin, &FreezeLimit);
+       vacuum_set_xid_limits(vacstmt->freeze_min_age, vacstmt->freeze_table_age,
+                                                 onerel->rd_rel->relisshared,
+                                                 &OldestXmin, &FreezeLimit, NULL);
 
        /*
         * Flush any previous async-commit transactions.  This does not guarantee
index 4a009a62e70b0d4f33d0ee685bc3cfa6fbf50402..63a6ffb440a8321ab7a1c7c7eb48fb6ebeaa11c7 100644 (file)
@@ -29,7 +29,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.116 2009/01/06 14:55:37 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.117 2009/01/16 13:27:23 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -144,6 +144,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
        BlockNumber possibly_freeable;
        PGRUsage        ru0;
        TimestampTz starttime = 0;
+       bool            scan_all;
+       TransactionId freezeTableLimit;
 
        pg_rusage_init(&ru0);
 
@@ -158,8 +160,11 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
 
        vac_strategy = bstrategy;
 
-       vacuum_set_xid_limits(vacstmt->freeze_min_age, onerel->rd_rel->relisshared,
-                                                 &OldestXmin, &FreezeLimit);
+       vacuum_set_xid_limits(vacstmt->freeze_min_age, vacstmt->freeze_table_age,
+                                                 onerel->rd_rel->relisshared,
+                                                 &OldestXmin, &FreezeLimit, &freezeTableLimit);
+       scan_all = TransactionIdPrecedesOrEquals(onerel->rd_rel->relfrozenxid,
+                                                                                        freezeTableLimit);
 
        vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats));
 
@@ -171,7 +176,7 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
        vacrelstats->hasindex = (nindexes > 0);
  
        /* Do the vacuuming */
-       lazy_scan_heap(onerel, vacrelstats, Irel, nindexes, vacstmt->scan_all);
+       lazy_scan_heap(onerel, vacrelstats, Irel, nindexes, scan_all);
 
        /* Done with indexes */
        vac_close_indexes(nindexes, Irel, NoLock);
index e88108c53f51a331614bdffaed434814bbc1357e..da1c65cfcca7661b608a74a9bc7f0b0f98f33b18 100644 (file)
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.419 2009/01/01 17:23:43 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.420 2009/01/16 13:27:23 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2865,7 +2865,7 @@ _copyVacuumStmt(VacuumStmt *from)
        COPY_SCALAR_FIELD(analyze);
        COPY_SCALAR_FIELD(verbose);
        COPY_SCALAR_FIELD(freeze_min_age);
-       COPY_SCALAR_FIELD(scan_all);
+       COPY_SCALAR_FIELD(freeze_table_age);
        COPY_NODE_FIELD(relation);
        COPY_NODE_FIELD(va_cols);
 
index 1c6d5b0c9bc44482bff717c3ca27ac9f6ffc27de..190750f2e19ee9efd6ed9cd4ee3cae8cb0862f70 100644 (file)
@@ -22,7 +22,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.344 2009/01/01 17:23:43 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.345 2009/01/16 13:27:23 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1454,7 +1454,7 @@ _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
        COMPARE_SCALAR_FIELD(analyze);
        COMPARE_SCALAR_FIELD(verbose);
        COMPARE_SCALAR_FIELD(freeze_min_age);
-       COMPARE_SCALAR_FIELD(scan_all);
+       COMPARE_SCALAR_FIELD(freeze_table_age);
        COMPARE_NODE_FIELD(relation);
        COMPARE_NODE_FIELD(va_cols);
 
index 448b7615988b96efcb3ba2348064d4d4a5d68611..cc1f812bd98fdc233d74ed50d9e90fd244037fcb 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.654 2009/01/12 09:38:30 petere Exp $
+ *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.655 2009/01/16 13:27:23 heikki Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -6263,7 +6263,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose
                                        n->analyze = false;
                                        n->full = $2;
                                        n->freeze_min_age = $3 ? 0 : -1;
-                                       n->scan_all = $2 || $3;
+                                       n->freeze_table_age = $3 ? 0 : -1;
                                        n->verbose = $4;
                                        n->relation = NULL;
                                        n->va_cols = NIL;
@@ -6276,7 +6276,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose
                                        n->analyze = false;
                                        n->full = $2;
                                        n->freeze_min_age = $3 ? 0 : -1;
-                                       n->scan_all = $2 || $3;
+                                       n->freeze_table_age = $3 ? 0 : -1;
                                        n->verbose = $4;
                                        n->relation = $5;
                                        n->va_cols = NIL;
@@ -6288,7 +6288,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose
                                        n->vacuum = true;
                                        n->full = $2;
                                        n->freeze_min_age = $3 ? 0 : -1;
-                                       n->scan_all = $2 || $3;
+                                       n->freeze_table_age = $3 ? 0 : -1;
                                        n->verbose |= $4;
                                        $$ = (Node *)n;
                                }
@@ -6302,6 +6302,7 @@ AnalyzeStmt:
                                        n->analyze = true;
                                        n->full = false;
                                        n->freeze_min_age = -1;
+                                       n->freeze_table_age = -1;
                                        n->verbose = $2;
                                        n->relation = NULL;
                                        n->va_cols = NIL;
@@ -6314,6 +6315,7 @@ AnalyzeStmt:
                                        n->analyze = true;
                                        n->full = false;
                                        n->freeze_min_age = -1;
+                                       n->freeze_table_age = -1;
                                        n->verbose = $2;
                                        n->relation = $3;
                                        n->va_cols = $4;
index ce90fa45abe68667c0be77a00ce44766c754d4d5..ed77c51c9fff116370a598c7b46a1be9bdd24b18 100644 (file)
@@ -55,7 +55,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.91 2009/01/01 17:23:46 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.92 2009/01/16 13:27:24 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -136,8 +136,9 @@ static volatile sig_atomic_t got_SIGTERM = false;
 /* Comparison point for determining whether freeze_max_age is exceeded */
 static TransactionId recentXid;
 
-/* Default freeze_min_age to use for autovacuum (varies by database) */
+/* Default freeze ages to use for autovacuum (varies by database) */
 static int     default_freeze_min_age;
+static int     default_freeze_table_age;
 
 /* Memory context for long-lived data */
 static MemoryContext AutovacMemCxt;
@@ -174,6 +175,7 @@ typedef struct autovac_table
        bool            at_dovacuum;
        bool            at_doanalyze;
        int                     at_freeze_min_age;
+       int                     at_freeze_table_age;
        int                     at_vacuum_cost_delay;
        int                     at_vacuum_cost_limit;
        bool            at_wraparound;
@@ -1857,7 +1859,7 @@ do_autovacuum(void)
        pgstat_vacuum_stat();
 
        /*
-        * Find the pg_database entry and select the default freeze_min_age. We
+        * Find the pg_database entry and select the default freeze ages. We
         * use zero in template and nonconnectable databases, else the system-wide
         * default.
         */
@@ -1869,9 +1871,15 @@ do_autovacuum(void)
        dbForm = (Form_pg_database) GETSTRUCT(tuple);
 
        if (dbForm->datistemplate || !dbForm->datallowconn)
+       {
                default_freeze_min_age = 0;
+               default_freeze_table_age = 0;
+       }
        else
+       {
                default_freeze_min_age = vacuum_freeze_min_age;
+               default_freeze_table_age = vacuum_freeze_table_age;
+       }
 
        ReleaseSysCache(tuple);
 
@@ -2418,6 +2426,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map)
        if (doanalyze || dovacuum)
        {
                int                     freeze_min_age;
+               int                     freeze_table_age;
                int                     vac_cost_limit;
                int                     vac_cost_delay;
 
@@ -2443,6 +2452,9 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map)
 
                        freeze_min_age = (avForm->freeze_min_age >= 0) ?
                                avForm->freeze_min_age : default_freeze_min_age;
+
+                       freeze_table_age = (avForm->freeze_table_age >= 0) ?
+                               avForm->freeze_table_age : default_freeze_table_age;
                }
                else
                {
@@ -2453,6 +2465,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map)
                                autovacuum_vac_cost_delay : VacuumCostDelay;
 
                        freeze_min_age = default_freeze_min_age;
+
+                       freeze_table_age = default_freeze_table_age;
                }
 
                tab = palloc(sizeof(autovac_table));
@@ -2460,6 +2474,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map)
                tab->at_dovacuum = dovacuum;
                tab->at_doanalyze = doanalyze;
                tab->at_freeze_min_age = freeze_min_age;
+               tab->at_freeze_table_age = freeze_table_age;
                tab->at_vacuum_cost_limit = vac_cost_limit;
                tab->at_vacuum_cost_delay = vac_cost_delay;
                tab->at_wraparound = wraparound;
@@ -2649,7 +2664,7 @@ autovacuum_do_vac_analyze(autovac_table *tab,
        vacstmt.full = false;
        vacstmt.analyze = tab->at_doanalyze;
        vacstmt.freeze_min_age = tab->at_freeze_min_age;
-       vacstmt.scan_all = tab->at_wraparound;
+       vacstmt.freeze_table_age = tab->at_freeze_table_age;
        vacstmt.verbose = false;
        vacstmt.relation = NULL;        /* not used since we pass a relid */
        vacstmt.va_cols = NIL;
index 63e9628a5dcfa8d4acafd0dbd405454dc43fc001..fbba0557d29bf50a7a6905b9962de4da55f2c21e 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.493 2009/01/12 05:10:44 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.494 2009/01/16 13:27:24 heikki Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -1544,7 +1544,16 @@ static struct config_int ConfigureNamesInt[] =
                        NULL
                },
                &vacuum_freeze_min_age,
-               100000000, 0, 1000000000, NULL, NULL
+               50000000, 0, 1000000000, NULL, NULL
+       },
+
+       {
+               {"vacuum_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+                       gettext_noop("Age at which VACUUM should scan whole table to freeze tuples."),
+                       NULL
+               },
+               &vacuum_freeze_table_age,
+               150000000, 0, 2000000000, NULL, NULL
        },
 
        {
index 977e13e0aff54e700567b211cf9d734524453294..a874b4541dbe004858dc84ab0d601c299761ddd9 100644 (file)
 #default_transaction_read_only = off
 #session_replication_role = 'origin'
 #statement_timeout = 0                 # 0 is disabled
-#vacuum_freeze_min_age = 100000000
+#vacuum_freeze_min_age = 50000000
+#vacuum_freeze_table_age = 150000000
 #xmlbinary = 'base64'
 #xmloption = 'content'
 
index 13e47f0399cf3e3bab73a567f6cca7cd497a5952..64a05e738d56e9003ab8ead4cf2a6cb636335521 100644 (file)
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.517 2009/01/05 17:14:28 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.518 2009/01/16 13:27:24 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     200901051
+#define CATALOG_VERSION_NO     200901161
 
 #endif
index 215af4c7398617b7078d69480f5410b4b4b22ce3..94eb05b925017bf2859731a523e501159286ef3d 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_autovacuum.h,v 1.10 2009/01/01 17:23:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_autovacuum.h,v 1.11 2009/01/16 13:27:24 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,6 +34,7 @@ CATALOG(pg_autovacuum,1248) BKI_WITHOUT_OIDS
        int4            vac_cost_limit; /* vacuum cost limit */
        int4            freeze_min_age; /* vacuum min freeze age */
        int4            freeze_max_age; /* max age before forcing vacuum */
+       int4            freeze_table_age; /* age at which vacuum scans whole table */
 } FormData_pg_autovacuum;
 
 /* ----------------
@@ -58,6 +59,7 @@ typedef FormData_pg_autovacuum *Form_pg_autovacuum;
 #define Anum_pg_autovacuum_vac_cost_limit                      8
 #define Anum_pg_autovacuum_freeze_min_age                      9
 #define Anum_pg_autovacuum_freeze_max_age                      10
+#define Anum_pg_autovacuum_freeze_table_age                    11
 
 /* There are no preloaded tuples in pg_autovacuum.h */
 
index c891dc5c867b9aa3dde1d983b7b3a1aa7a570211..f5f6cf4aa8ca69c94dedec907509b949fdda8404 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.83 2009/01/01 17:23:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.84 2009/01/16 13:27:24 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -122,6 +122,7 @@ typedef struct VacAttrStats
 extern PGDLLIMPORT int default_statistics_target;              /* PGDLLIMPORT for
                                                                                                                 * PostGIS */
 extern int     vacuum_freeze_min_age;
+extern int     vacuum_freeze_table_age;
 
 
 /* in commands/vacuum.c */
@@ -135,9 +136,11 @@ extern void vac_update_relstats(Relation relation,
                                        double num_tuples,
                                        bool hasindex,
                                        TransactionId frozenxid);
-extern void vacuum_set_xid_limits(int freeze_min_age, bool sharedRel,
+extern void vacuum_set_xid_limits(int freeze_min_age, int freeze_table_age,
+                                         bool sharedRel,
                                          TransactionId *oldestXmin,
-                                         TransactionId *freezeLimit);
+                                         TransactionId *freezeLimit,
+                                         TransactionId *freezeTableLimit);
 extern void vac_update_datfrozenxid(void);
 extern bool vac_is_partial_index(Relation indrel);
 extern void vacuum_delay_point(void);
index ebba76fbc36505c77c111ad177ebf99bc4a94f8f..ce225f801eb70442be8cf15b5df0194bee270f65 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.387 2009/01/01 17:24:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.388 2009/01/16 13:27:24 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2155,8 +2155,8 @@ typedef struct VacuumStmt
        bool            full;                   /* do FULL (non-concurrent) vacuum */
        bool            analyze;                /* do ANALYZE step */
        bool            verbose;                /* print progress info */
-       bool            scan_all;               /* force scan of all pages */
        int                     freeze_min_age; /* min freeze age, or -1 to use default */
+       int                     freeze_table_age; /* age at which to scan whole table */
        RangeVar   *relation;           /* single table to process, or NULL */
        List       *va_cols;            /* list of column names, or NIL for all */
 } VacuumStmt;