X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5B38B9F9CAA for ; Fri, 16 Jun 2006 04:23:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 36722-03-3 for ; Fri, 16 Jun 2006 04:22:53 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id CF0AA9FA61D for ; Fri, 16 Jun 2006 04:22:50 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so644647ugf for ; Fri, 16 Jun 2006 00:22:49 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=O49MmkMm+vW/1CJMZ1yUre0h0Iifr+A7M5d11r+Qz5UVqcN6WZkiElVEKJ+r8h8mFyPsEPnjcjGRV3Os2IO6Lk9rPMjQmn7IjN6Il7ZjPAh2RN8xGgKrDgdVIpspzxMJZ9UJ/xHVfKCu/HHpDfsHwM58hJc3kfhCJebTEtUFuwI= Received: by 10.66.252.4 with SMTP id z4mr2466004ugh; Fri, 16 Jun 2006 00:22:49 -0700 (PDT) Received: by 10.66.220.11 with HTTP; Fri, 16 Jun 2006 00:22:49 -0700 (PDT) Message-ID: <674d1f8a0606160022p1b042676gba28553bac5ab5ea@mail.gmail.com> Date: Fri, 16 Jun 2006 12:52:49 +0530 From: "Gourish Singbal" To: postgres@leangen.net Subject: Re: Delete operation VERY slow... Cc: pgsql-performance@postgresql.org In-Reply-To: <1150441126.4812.23.camel@sonoda.bioscene.co.jp> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_14240_27707044.1150442569047" References: <1150441126.4812.23.camel@sonoda.bioscene.co.jp> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/340 X-Sequence-Number: 19697 ------=_Part_14240_27707044.1150442569047 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline David, Truncate table would be a good idea if u want to delete all the data in the table. You need not perform vacuum in this case since there are no dead rows created. ~gourish On 6/16/06, David Leangen wrote: > > > Hello! > > I am trying to delete an entire table. There are about 41,000 rows in > the table (based on count(*)). > > I am using the SQL comment: delete from table; > > The operation seems to take in the order of hours, rather than seconds > or minutes. > > "Explain delete from table" gives me: > > QUERY PLAN > ---------------------------------------------------------------- > Seq Scan on table (cost=0.00..3967.74 rows=115374 width=6) > (1 row) > > > I am using an Intel Pentium D 2.8GHz CPU. My system has about 1.2GB of > RAM. This should be ok... my database isn't that big, I think. > > > Any ideas why this takes so long and how I could speed this up? > > Or alternatively, is there a better way to delete all the contents from > a table? > > > Thank you! > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > -- Best, Gourish Singbal ------=_Part_14240_27707044.1150442569047 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
 
David,
 
Truncate table would be a good idea if u want to delete all the data in the table.
You need not perform vacuum in this case since there are no dead rows created.
 
~gourish

 
On 6/16/06, David Leangen <postgres@leangen.net> wrote:

Hello!

I am trying to delete an entire table. There are about 41,000 rows in
the table (based on count(*)).

I am using the SQL comment: delete from table;

The operation seems to take in the order of hours, rather than seconds
or minutes.

"Explain delete from table" gives me:

                          QUERY PLAN
----------------------------------------------------------------
Seq Scan on table  (cost=0.00..3967.74 rows=115374 width=6)
(1 row)


I am using an Intel Pentium D 2.8GHz CPU. My system has about 1.2GB of
RAM. This should be ok... my database isn't that big, I think.


Any ideas why this takes so long and how I could speed this up?

Or alternatively, is there a better way to delete all the contents from
a table?


Thank you!



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



--
Best,
Gourish Singbal ------=_Part_14240_27707044.1150442569047--