X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id B11473103DB for ; Sat, 28 Jun 2003 00:00:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 64431-04 for ; Fri, 27 Jun 2003 20:59:57 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id CD9383103BC for ; Fri, 27 Jun 2003 20:59:56 -0300 (ADT) Received: (qmail 22754 invoked by uid 500); 28 Jun 2003 00:03:28 -0000 Date: Fri, 27 Jun 2003 19:03:28 -0500 From: Bruno Wolff III To: Matthew Hixson Cc: pgsql-sql@postgresql.org Subject: Re: need some help with a delete statement Message-ID: <20030628000328.GB21761@wolff.to> Mail-Followup-To: Matthew Hixson , pgsql-sql@postgresql.org References: <6915DFA6-A8F4-11D7-81EC-000393669C1A@poindextrose.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6915DFA6-A8F4-11D7-81EC-000393669C1A@poindextrose.org> User-Agent: Mutt/1.5.4i X-Archive-Number: 200306/324 X-Sequence-Number: 14082 On Fri, Jun 27, 2003 at 16:09:31 -0700, Matthew Hixson wrote: > Hi, I have a bunch of records that I need to delete from our database. > These records represent shopping carts for visitors to our website. > The shopping carts I'd like to delete are the ones without anything in > them. Here is the schema: IN is slow in 7.3.3 and below. It will be substantially faster in 7.4. In the meantime rewriting your query to use not exists will probably speed things up for you. Delete also allows for joins with other tables which doesn't help in thsi particular case (at least not any way I can think of), but is help for deleting items there are in (as opposed to are not in) another table.