pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: pginfo <pginfo@t1.unisoftbg.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: update and IN vs. EXISTS
Date: Sat, 1 Feb 2003 08:54:12 -0600
Message-ID: <20030201145412.GA29037@wolff.to> (raw)
In-Reply-To: <3E3BB210.5C51478C@t1.unisoftbg.com>
References: <3E3BB210.5C51478C@t1.unisoftbg.com>

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.



view thread (4+ messages)  latest in thread

Message-ID: <20030201145412.GA29037@wolff.to>
Permalink:  ../20030201145412.GA29037@wolff.to/
Also on:    postgresql.org/message-id/20030201145412.GA29037@wolff.to

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, pginfo@t1.unisoftbg.com
  Subject: Re: update and IN vs. EXISTS
  In-Reply-To: <20030201145412.GA29037@wolff.to>

* 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