X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 82101D6F4A for ; Thu, 20 Oct 2005 05:50:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48799-05 for ; Thu, 20 Oct 2005 08:50:21 +0000 (GMT) Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) by svr1.postgresql.org (Postfix) with ESMTP id 7CDA1DA838 for ; Thu, 20 Oct 2005 05:50:22 -0300 (ADT) Received: from [192.168.1.110] (unknown [192.168.1.110]) by mail.ecircle.de (READY) with ESMTP id 78A5F11DE6C; Thu, 20 Oct 2005 10:50:24 +0200 (CEST) Subject: Re: Deleting Records From: Csaba Nagy To: "Christian Paul B. Cosinas" Cc: postgres performance list In-Reply-To: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147> References: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147> Content-Type: text/plain Message-Id: <1129798144.27587.152.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 20 Oct 2005 10:49:04 +0200 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.325 required=5 tests=[AWL=-0.304, URIBL_SBL=0.629] X-Spam-Level: X-Archive-Number: 200510/276 X-Sequence-Number: 15044 Christian, Do you have foreign keys pointing to your table with ON CASCADE... ? Cause in that case you're not only deleting your 22000 records, but the whole tree of cascades. And if you don't have an index on one of those foreign keys, then you might have a sequential scan of the child table on each deleted row... I would check the foreign keys. HTH, Csaba. On Thu, 2005-10-20 at 10:43, Christian Paul B. Cosinas wrote: > Hi! > > I'm experiencing a very slow deletion of records. Which I thin is not right. > I have a Dual Xeon Server with 6gig Memory. > I am only deleting about 22,000 records but it took me more than 1 hour to > finish this. > > What could possibly I do so that I can make this fast? > > Here is the code inside my function: > > FOR temp_rec IN SELECT * FROM item_qc_doer LOOP > DELETE FROM qc_session WHERE item_id = temp_rec.item_id; > DELETE FROM item_qc_doer WHERE item_id = temp_rec.item_id; > END LOOP; > > Item_qc_oder table contains 22,000 records. > > > I choose Polesoft Lockspam to fight spam, and you? > http://www.polesoft.com/refer.html > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend