X-Original-To: pgsql-admin@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DA3FD476DBE for ; Sat, 17 May 2003 05:18:13 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 50668-07 for ; Sat, 17 May 2003 05:18:12 -0400 (EDT) Received: from shield.nordlb.lv (shield.pirmabanka.lv [195.114.57.4]) by postgresql.org (Postfix) with ESMTP id 6197947630C for ; Sat, 17 May 2003 05:18:11 -0400 (EDT) Received: from wall2.pirmabanka.lv (wall2-pub.nordlb.lv [195.114.57.14]) by shield.nordlb.lv (8.12.9/8.12.9) with SMTP id h4H9IBbg018705 for ; Sat, 17 May 2003 12:18:11 +0300 Received: from share.nordlb.lv ([10.0.0.10]) by wall2.pirmabanka.lv; Sat, 17 May 2003 12:18:10 +0300 (EET DST) Received: from pc311x1.nordlb.lv (localhost.localdomain [127.0.0.1]) by nordlb.lv (8.11.6/8.11.6) with SMTP id h4H9I9K05688 for ; Sat, 17 May 2003 12:18:10 +0300 Received: (qmail 2863 invoked by uid 100); 17 May 2003 09:20:55 -0000 Date: Sat, 17 May 2003 12:20:55 +0300 From: "Victor Yegorov" To: "Kuhn, Dylan K (4520500D)" Cc: Subject: Re: bulk DELETE speed Message-ID: <20030517092055.GC1551@nordlb.lv> Mail-Followup-To: "Kuhn, Dylan K (4520500D)" , References: <78ED1F30F0D85B4698FBD6CF2A5AC8F5A576D4@NAWECHLKEX01VA.nadsuswe.nads.navy.mil> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <78ED1F30F0D85B4698FBD6CF2A5AC8F5A576D4@NAWECHLKEX01VA.nadsuswe.nads.navy.mil> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/251 X-Sequence-Number: 8813 * Kuhn, Dylan K (4520500D) [16.05.2003 20:31]: > > I'm trying to figure out why deletes are slow on a particular table. > > I have a few tables with millions of rows, and have noticed that deleting rows is many times slower on one of them. It does have PL/PGSQL before and after delete triggers. I've tried disabling the triggers in pg_trigger, dropping them, doing the deletes in transactions, with exclusive locks -- nothing seems to work. Maybe it isn't the triggers at all, and I need to do some sort of analysis on my table to figure out why it is slow? > > Does anyone have any other tricks for speeding up bulk deletes? A couple of days ago I've found the same problem. Check, if your table has a primary key (guess it does), thatis referenced by any other tables. If so, for each row you're deleteing, backend first is checking for existance of related ones in other tables. In my case, those "othertables" wasn't indexed by the foreign key field. That means - for each row to delete backend is performing seq. scan on some other table. Even if it isn't so big, it still slows down the things. Look around, may be this will help. -- Victor Yegorov