Reference

purge(7l)

discard historical data

NAME

purge — discard historical data

SYNOPSIS

purge classname [ before abstime ] [ after reltime ]

DESCRIPTION

Purge allows a user to specify the historical retention properties of a class. If the date specified is an absolute time such as “Jan 1 1987”, Postgres will discard tuples whose validity expired before the indicated time. Purge with no before clause is equivalent to “purge before now”. Until specified with a purge command, instance preservation defaults to “forever”.

The user may purge a class at any time as long as the purge date never decreases. Postgres will enforce this restriction, silently.

Note that the purge command does not do anything except set a parameter for system operation. Use vacuum(l) to enforce this parameter.

EXAMPLE

--
--Always discard data in the EMP class
--prior to January 1, 1989
--
purge EMP before "Jan 1 1989"

--
--Retain only the current data in EMP
--
purge EMP

SEE ALSO

vacuum(l).

BUGS AND CAVEATS

Error messages are quite unhelpful. A complaint about “inconsistent times” followed by several nine-digit numbers indicates an attempt to “back up” a purge date on a relation.

You cannot purge certain system catalogs (namely, “pg_class”, “pg_attribute”, “pg_am”, and “pg_amop”) due to circularities in the system catalog code.

This definition of the purge command is really only useful for non-archived relations, since tuples will not be discarded from archive relations (they are never vacuumed).

History