Thread: Fast deletes

Fast deletes

From
Jason Hihn
Date:
I'm looking for a fast way to completely clear a table that does not involve
dropping it. Essentially, I want the table to get empty quick. I can
understand why DELETE can be much slower than a drop and recreate of the
table, however none of those reasons apply here. There are no cascades on
the tables I wish to drop, and the table clearing happens w.r.t. keys. That
is to say, I clear out the leaf tables first and work up the stem, whenever
there are dependencies.

I was hoping there would be something like a truncate command that would
just rest the table blindly. Is there such a way? I don't like the drop
table idea because if the file for the schema isn't available (offline disk
or something) then I'd be fubar.

Currently, it takes several minutes (10+) to of empty one of my biggest 3
tables, and the entire time postmaster is pegged at 99.8% CPU. (90% of that
is "system").

The machine isn't using any swap memory either...
Thanks,

Jason Hihn




Re: Fast deletes

From
Tom Lane
Date:
Jason Hihn <jhihn@paytimepayroll.com> writes:
> I was hoping there would be something like a truncate command that would
> just rest the table blindly. Is there such a way?

http://www.postgresql.org/docs/7.3/static/sql-truncate.html

            regards, tom lane

Re: Fast deletes

From
Nabil Sayegh
Date:
Am Don, 2003-08-14 um 15.28 schrieb Jason Hihn:

> I was hoping there would be something like a truncate command that would
> just rest the table blindly. Is there such a way? I don't like the drop
> table idea because if the file for the schema isn't available (offline disk
> or something) then I'd be fubar.

AFAIR truncate is supported
--
 e-Trolley Sayegh & John, Nabil Sayegh
 Tel.: 0700 etrolley /// 0700 38765539
 Fax.: +49 69 8299381-8
 PGP : http://www.e-trolley.de