Re: Long-running DELETE...WHERE...

From: Chester Carlton Young <chestercyoung(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Long-running DELETE...WHERE...
Date: 2002-01-15 02:04:15
Message-ID: 20020115020415.45801.qmail@web12702.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Nice syntax. Could not find in doc. Do you have any ideas where I
could find it?

--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> jboes(at)nexcerpt(dot)com (Jeff Boes) writes:
> > My situation: table A has 200,000 rows. I've made up a temporary
> table
> > which holds the single-valued primary key for 80,000 rows which I
> want
> > to delete.
> > DELETE FROM a WHERE id IN (select ID from tmp LIMIT 800);
> > runs for several minutes.
>
> WHERE ... IN ... is notoriously inefficient. I'd try
>
> DELETE FROM aa WHERE id = tmp.id;
>
> which is not standard SQL but should be able to produce a decent
> plan.
>
> You might find that a VACUUM ANALYZE on both tables beforehand would
> be
> a good idea, too; never-vacuumed temp tables have some default
> statistics assumed that are a lot less than 80k rows.
>
> regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gurudutt 2002-01-15 04:45:40 Re: Resources - Regular Expressions
Previous Message Tom Lane 2002-01-15 01:21:10 Re: Long-running DELETE...WHERE...