Re: update and IN vs. EXISTS

From: pginfo <pginfo(at)t1(dot)unisoftbg(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: update and IN vs. EXISTS
Date: 2003-02-01 13:49:46
Message-ID: 3E3BD07A.CC796690@t1.unisoftbg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bruno Wolff III wrote:

> On Sat, Feb 01, 2003 at 12:40:00 +0100,
> pginfo <pginfo(at)t1(dot)unisoftbg(dot)com> wrote:
> >
> > If I try to execute:
> > update Table1 set fieldForUpdate = 1 where ID IN (select T2.ID from
> > Table2);
> > it is running very slow.
>
> You might try:
> update Table1 set fieldForUpdate = 1 from Table2 where Table1.id = Table2.id;
>

It is great.It takes 122 sec.
With IN it takes 8000 sec.

> This uses a nonstandard postgres extension and may not be portable, if that
> is a concern.
>

How to resolve the problem with the standart?regards,
iavn.

> INs are being speeded up in 7.4, so the original form might work a lot better
> in the next release.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2003-02-01 14:16:08 Re: vacuum and serial primary keys
Previous Message Carmen Marincu 2003-02-01 12:45:24 vacuum and serial primary keys