From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Kevin Kempter <cs_dba@consistentstate.com>
To: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Update join performance issues
Date: Tue, 03 Apr 2012 12:37:50 -0500
Message-ID: <4F7AEF1E0200002500046B35@gw.wicourts.gov> (raw)
In-Reply-To: <4F7B3394.3030703@consistentstate.com>
References: <4F7B3394.3030703@consistentstate.com>
Kevin Kempter <cs_dba@consistentstate.com> wrote:
> update test_one
> set f_key = t.f_key
> from
> upd_temp1 t,
> test_one t2
> where
> t.id_number = t2.id_number
As written above, it is joining the two table references in the FROM
clause and updating every row in test_one with every row in the JOIN
-- which is probably not what you want. Having a FROM clause on an
UPDATE statement is not something which is covered by the standard,
and different products have implemented different semantics for
that. For example, under MS SQL Server, the first reference in the
FROM clause to the target of the UPDATE is considered to be the same
reference; so the above statement would be accepted, but do
something very different.
You probably want this:
update test_one t2
set f_key = t.f_key
from
upd_temp1 t
where
t.id_number = t2.id_number
-Kevin
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, cs_dba@consistentstate.com
Subject: Re: Update join performance issues
In-Reply-To: <4F7AEF1E0200002500046B35@gw.wicourts.gov>
References: <4F7B3394.3030703@consistentstate.com> <4F7AEF1E0200002500046B35@gw.wicourts.gov>
* 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