X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ED362D1B505 for ; Sun, 12 Oct 2003 05:27:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83011-08 for ; Sun, 12 Oct 2003 02:27:03 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 85AD3D1B508 for ; Sun, 12 Oct 2003 02:26:49 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92JZYV>; Sat, 11 Oct 2003 22:25:26 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92JZY4; Sat, 11 Oct 2003 22:25:24 -0700 From: David Griffiths To: Stephan Szabo Cc: pgsql-performance@postgresql.org Message-ID: <06d701c39082$ae32aa10$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> Subject: Re: Another weird one with an UPDATE Date: Sat, 11 Oct 2003 22:35:39 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/398 X-Sequence-Number: 4146 Thanks - that worked. David ----- Original Message ----- From: "Stephan Szabo" To: "David Griffiths" Cc: Sent: Saturday, October 11, 2003 3:34 PM Subject: Re: [PERFORM] Another weird one with an UPDATE > On Sat, 11 Oct 2003, David Griffiths wrote: > > > Sorry - just found the FAQ ( > > http://jamesthornton.com/postgres/FAQ/faq-english.html#4.22 > > ) on how > > IN is very slow. > > > > So I rewrote the query: > > > > \o ./data/temp.txt > > SELECT current_timestamp; > > UPDATE user_account SET last_name = 'abc' > > WHERE EXISTS (SELECT ua.user_account_id FROM user_account ua, > > commercial_entity ce, commercial_service cs > > WHERE ua.user_account_id = ce.user_account_id AND > > ce.commercial_entity_id = cs.commercial_entity_id); > > SELECT current_timestamp; > > I don't think that's the query you want. You're not binding the subselect > to the outer values of user_account. > > I think you want something like: > UPDATE user_account SET last_name = 'abc' > WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs > WHERE user_account.user_account_id = ce.user_account_id AND > ce.commercial_entity_id = cs.commercial_entity_id);