X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 20B81D1DF71 for ; Tue, 24 Feb 2004 02:25:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 42223-02 for ; Mon, 23 Feb 2004 22:25:20 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 249D0D1DD65 for ; Mon, 23 Feb 2004 22:25:16 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1O2PDGi013606; Tue, 24 Feb 2004 10:25:13 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <403AB818.9090100@familyhealth.com.au> Date: Tue, 24 Feb 2004 10:34:00 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Ed L." Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORMANCE] slow small delete on large table References: <200402231910.57078.pgsql@bluepolka.net> In-Reply-To: <200402231910.57078.pgsql@bluepolka.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/271 X-Sequence-Number: 5795 > Of course, that's not legal 7.3.4 syntax. These are both too > slow due to sequential scan of table: > > delete from mytable where key in ( > select key > from mytable > where posteddatetime < now() - '90 days' > limit 100); Upgrade to 7.4 - the query above will be vastly faster. > delete from mytable where exists ( > select m.key > from mytable m > where m.key = mytable.key > and m.posteddatetime < now() - '90 days' > limit 100); That one I used to use on 7.3 - I seem to recall it indexed nicely. Chris