X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D066A4758C9 for ; Sat, 1 Feb 2003 09:48:20 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 8B1F8474E53 for ; Sat, 1 Feb 2003 09:48:17 -0500 (EST) Received: (qmail 22463 invoked from network); 1 Feb 2003 16:24:59 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 1 Feb 2003 16:24:59 -0000 Message-ID: <3E3BD07A.CC796690@t1.unisoftbg.com> Date: Sat, 01 Feb 2003 14:49:46 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Bruno Wolff III Cc: "pgsql-sql@postgresql.org" Subject: Re: update and IN vs. EXISTS References: <3E3BB210.5C51478C@t1.unisoftbg.com> <20030201145412.GA29037@wolff.to> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/9 X-Sequence-Number: 11407 Bruno Wolff III wrote: > 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; > 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