X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1B4354758DC for ; Sat, 1 Feb 2003 09:41:15 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 44AD0474E53 for ; Sat, 1 Feb 2003 09:41:14 -0500 (EST) Received: (qmail 29068 invoked by uid 500); 1 Feb 2003 14:54:12 -0000 Date: Sat, 1 Feb 2003 08:54:12 -0600 From: Bruno Wolff III To: pginfo Cc: "pgsql-sql@postgresql.org" Subject: Re: update and IN vs. EXISTS Message-ID: <20030201145412.GA29037@wolff.to> Mail-Followup-To: pginfo , "pgsql-sql@postgresql.org" References: <3E3BB210.5C51478C@t1.unisoftbg.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E3BB210.5C51478C@t1.unisoftbg.com> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/8 X-Sequence-Number: 11406 On Sat, Feb 01, 2003 at 12:40:00 +0100, pginfo 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.