From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: Ed L. <pgsql@bluepolka.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORMANCE] slow small delete on large table
Date: Tue, 24 Feb 2004 10:34:00 +0800
Message-ID: <403AB818.9090100@familyhealth.com.au> (raw)
In-Reply-To: <200402231910.57078.pgsql@bluepolka.net>
References: <200402231910.57078.pgsql@bluepolka.net>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: chriskl@familyhealth.com.au, pgsql@bluepolka.net
Subject: Re: [PERFORMANCE] slow small delete on large table
In-Reply-To: <403AB818.9090100@familyhealth.com.au>
References: <200402231910.57078.pgsql@bluepolka.net> <403AB818.9090100@familyhealth.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox