Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E98A4650EAA for ; Fri, 4 Jul 2008 12:48:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75390-06 for ; Fri, 4 Jul 2008 12:48:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from skynet.simkin.ca (skynet.simkin.ca [72.51.27.117]) by postgresql.org (Postfix) with ESMTP id 0D98B650E9D for ; Fri, 4 Jul 2008 12:48:23 -0300 (ADT) Received: from charon.medialogik.com (charon.medialogik.com [72.51.27.114]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by skynet.simkin.ca (Postfix) with ESMTP id 25CA54A9E for ; Fri, 4 Jul 2008 08:48:20 -0700 (PDT) From: Alan Hodgson Organization: Simkin Network Consulting To: pgsql-performance@postgresql.org Subject: Re: slow delete Date: Fri, 4 Jul 2008 08:48:19 -0700 User-Agent: KMail/1.9.9 References: <498125.4752.qm@web56401.mail.re3.yahoo.com> <31248.217.77.161.17.1215176449.squirrel@sq.gransy.com> In-Reply-To: <31248.217.77.161.17.1215176449.squirrel@sq.gransy.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200807040848.19462@hal.medialogik.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/48 X-Sequence-Number: 30648 On Friday 04 July 2008, tv@fuzzy.cz wrote: > > My next question is: what is the difference between "select" and > > "delete"? There is another table that has one foreign key to reference > > the test (parent) table that I am deleting from and this foreign key > > does not have an index on it (a 330K row table). > Yeah you need to fix that. You're doing 80,000 sequential scans of that table to do your delete. That's a whole lot of memory access ... I don't let people here create foreign key relationships without matching indexes - they always cause problems otherwise. -- Alan