1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Improve the -l (limit) option recently added to contrib/vacuumlo.

Instead of just stopping after removing an arbitrary subset of orphaned
large objects, commit and start a new transaction after each -l objects.
This is just as effective as the original patch at limiting the number of
locks used, and it doesn't require doing the OID collection process
repeatedly to get everything.  Since the option no longer changes the
fundamental behavior of vacuumlo, and it avoids a known server-side
limitation, enable it by default (with a default limit of 1000 LOs per
transaction).

In passing, be more careful about properly quoting the names of tables
and fields, and do some other cosmetic cleanup.
This commit is contained in:
Tom Lane
2012-03-20 19:05:08 -04:00
parent 9d23a70d51
commit 64c604898e
2 changed files with 109 additions and 48 deletions

View File

@ -50,19 +50,22 @@ vacuumlo [options] database [database2 ... databaseN]
</varlistentry>
<varlistentry>
<term><option>-U</option> <replaceable>username</></term>
<term><option>-l</option> <replaceable>limit</></term>
<listitem>
<para>User name to connect as.</para>
<para>
Remove no more than <replaceable>limit</> large objects per
transaction (default 1000). Since the server acquires a lock per LO
removed, removing too many LOs in one transaction risks exceeding
<xref linkend="guc-max-locks-per-transaction">. Set the limit to
zero if you want all removals done in a single transaction.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-l</option> <replaceable>limit</></term>
<term><option>-U</option> <replaceable>username</></term>
<listitem>
<para>
Stop after removing LIMIT large objects. Useful to avoid
exceeding <xref linkend="guc-max-locks-per-transaction">.
</para>
<para>User name to connect as.</para>
</listitem>
</varlistentry>
@ -120,18 +123,19 @@ vacuumlo [options] database [database2 ... databaseN]
<title>Method</title>
<para>
First, it builds a temporary table which contains all of the OIDs of the
large objects in that database.
First, <application>vacuumlo</> builds a temporary table which contains all
of the OIDs of the large objects in the selected database.
</para>
<para>
It then scans through all columns in the database that are of type
<type>oid</> or <type>lo</>, and removes matching entries from the
temporary table.
temporary table. (Note: only types with these names are considered;
in particular, domains over them are not considered.)
</para>
<para>
The remaining entries in the temp table identify orphaned LOs.
The remaining entries in the temporary table identify orphaned LOs.
These are removed.
</para>
</sect2>