Heikki Linnakangas <[EMAIL PROTECTED]> writes:
> On Tue, 2 May 2006, Tom Lane wrote:
>> Also, as noted in other contexts, it'd be a good idea if vacuumcleanup
>> was told the total number of heap tuples (GIN needs this), and both
>> steps really ought to be able to find out if it's a full or lazy vacuum.

> It's already in IndexVacuumCleanupInfo, isn't it?

Yeah, I had forgotten that, but just noticed it again now.  The patch
I'm working on at the moment defines

 * Struct for input arguments passed to ambulkdelete and amvacuumcleanup
 * Note that num_heap_tuples will not be valid during ambulkdelete,
 * only amvacuumcleanup.
typedef struct IndexVacuumInfo
    Relation    index;            /* the index being vacuumed */
    bool        vacuum_full;    /* VACUUM FULL (we have exclusive lock) */
    int         message_level;    /* ereport level for progress messages */
    double      num_heap_tuples;    /* tuples remaining in heap */
} IndexVacuumInfo;


IndexBulkDeleteResult *
ambulkdelete (IndexVacuumInfo *info,
              IndexBulkDeleteResult *stats,
              IndexBulkDeleteCallback callback,
              void *callback_state);

   Because of limited <varname>maintenance_work_mem</>,
   <function>ambulkdelete</> may need to be called more than once when many
   tuples are to be deleted.  The <literal>stats</> argument is the result
   of the previous call for this index (it is NULL for the first call within a
   <command>VACUUM</> operation).  This allows the AM to accumulate statistics
   across the whole operation.  Typically, <function>ambulkdelete</> will
   modify and return the same struct if the passed <literal>stats</> is not

IndexBulkDeleteResult *
amvacuumcleanup (IndexVacuumInfo *info,
                 IndexBulkDeleteResult *stats);

   Clean up after a <command>VACUUM</command> operation (zero or more
   <function>ambulkdelete</> calls).  This does not have to do anything
   beyond returning index statistics, but it may perform bulk cleanup
   such as reclaiming empty index pages.  <literal>stats</> is whatever the
   last <function>ambulkdelete</> call returned, or NULL if
   <function>ambulkdelete</> was not called because no tuples needed to be
   deleted.  If the result is not NULL it must be a palloc'd struct.
   The statistics it contains will be reported by <command>VACUUM</> if
   <literal>VERBOSE</> is given.

> BTW: Is it possible to have a partial gist index? If it is, 
> num_index_tuples = num_heap_tuples isn't right.

It is, and it isn't ;-).  We'll need to see about fixing that.

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to