Re: [PERFORMANCE] slow small delete on large table

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORMANCE] slow small delete on large table
Date: 2004-02-24 02:34:00
Message-ID: 403AB818.9090100@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Bruno Wolff III 2004-02-24 03:00:17 Re: [PERFORMANCE] slow small delete on large table
Previous Message Ed L. 2004-02-24 02:10:57 [PERFORMANCE] slow small delete on large table