From: | David Griffiths <dgriffiths(at)boats(dot)com> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Another weird one with an UPDATE |
Date: | 2003-10-12 05:35:39 |
Message-ID: | 06d701c39082$ae32aa10$6501a8c0@griffiths2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Thanks - that worked.
David
----- Original Message -----
From: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>
To: "David Griffiths" <dgriffiths(at)boats(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
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
> > <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);
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2003-10-12 19:28:27 | Re: Index/Foreign Key Question |
Previous Message | Christopher Kings-Lynne | 2003-10-12 02:43:35 | Re: go for a script! / ex: PostgreSQL vs. MySQL |