Re: update and IN vs. EXISTS - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: update and IN vs. EXISTS
Date
Msg-id 20030201145412.GA29037@wolff.to
Whole thread Raw
In response to update and IN vs. EXISTS  (pginfo <pginfo@t1.unisoftbg.com>)
List pgsql-sql
On Sat, Feb 01, 2003 at 12:40:00 +0100, pginfo <pginfo@t1.unisoftbg.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;

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

INs are being speeded up in 7.4, so the original form might work a lot better
in the next release.


pgsql-sql by date:

Previous
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: vacuum and serial primary keys
Next
From: pginfo
Date:
Subject: Re: update and IN vs. EXISTS