<!-- $PostgreSQL: pgsql/doc/src/sgml/vacuumlo.sgml,v 1.2 2007/12/06 04:12:10 tgl Exp $ -->

<sect1 id="vacuumlo">
 <title>vacuumlo</title>

 <indexterm zone="vacuumlo">
  <primary>vacuumlo</primary>
 </indexterm>

 <para>
  <application>vacuumlo</> is a simple utility program that will remove any
  <quote>orphaned</> large objects from a
  <productname>PostgreSQL</> database.  An orphaned large object (LO) is
  considered to be any LO whose OID does not appear in any <type>oid</> or
  <type>lo</> data column of the database.
 </para>

 <para>
  If you use this, you may also be interested in the <function>lo_manage</>
  trigger in <filename>contrib/lo</> (see <xref linkend="lo">).
  <function>lo_manage</> is useful to try
  to avoid creating orphaned LOs in the first place.
 </para>

 <sect2>
  <title>Usage</title>

  <synopsis>
vacuumlo [options] database [database2 ... databaseN]
  </synopsis>

  <para>
   All databases named on the command line are processed.  Available options
   include:
  </para>

  <variablelist>
   <varlistentry>
    <term><option>-v</option></term>
    <listitem>
     <para>Write a lot of progress messages</para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-n</option></term>
    <listitem>
     <para>Don't remove anything, just show what would be done</para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-U</option> <replaceable>username</></term>
    <listitem>
     <para>Username to connect as</para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-W</option></term>
    <listitem>
     <para>Force prompt for password (generally useless)</para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-h</option> <replaceable>hostname</></term>
    <listitem>
     <para>Database server's host</para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><option>-p</option> <replaceable>port</></term>
    <listitem>
     <para>Database server's port</para>
    </listitem>
   </varlistentry>
  </variablelist>
 </sect2>

 <sect2>
  <title>Method</title>

  <para>
   First, it builds a temporary table which contains all of the OIDs of the
   large objects in that 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.
  </para>

  <para>
   The remaining entries in the temp table identify orphaned LOs.
   These are removed.
  </para>
 </sect2>

 <sect2>
  <title>Author</title>

  <para>
   Peter Mount <email>peter@retep.org.uk</email>
  </para>
 </sect2>

</sect1>
