pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedupdate - which way quicker?
2+ messages / 2 participants
[nested] [flat]
* update - which way quicker?
@ 2008-08-28 19:31 Emi Lu <emilu@encs.concordia.ca>
2008-08-28 21:13 ` Re: update - which way quicker? paul socha <pawel.socha@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Emi Lu @ 2008-08-28 19:31 UTC (permalink / raw)
To: pgsql-performance
Good morning,
Tried to compare Table1 based on Table2
. update table1.col = false
if table1.pk_cols not in table2.pk_cols
For the following two ways, (2) always performs better than (1) right,
and I need your inputs.
========================================================================
(1) update table1
set col = false
where table1.pk_co1 || table1.pk_col2.... || table1.pk_colN
NOT IN
(select pk_co1 || pk_col2.... || pk_colN
from table2
)
(2) ResultSet(rs) =
select pk_col1||pk_col2... || pk_colN
from table1
left join table2 using (pk_col1..., pk_colN)
where table2.pk_col1 is null
Then for each rs record, do:
update table1
set col = false
where col1||... colN in rs.value
Thanks a lot!
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: update - which way quicker?
2008-08-28 19:31 update - which way quicker? Emi Lu <emilu@encs.concordia.ca>
@ 2008-08-28 21:13 ` paul socha <pawel.socha@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: paul socha @ 2008-08-28 21:13 UTC (permalink / raw)
To: emilu@encs.concordia.ca; +Cc: pgsql-performance
On 2008-08-28, at 21:31, Emi Lu wrote:
> Good morning,
>
> Tried to compare Table1 based on Table2
>
> . update table1.col = false
> if table1.pk_cols not in table2.pk_cols
>
>
>
> For the following two ways, (2) always performs better than (1) right,
> and I need your inputs.
> ======================================================================
> ==
> (1) update table1
> set col = false
> where table1.pk_co1 || table1.pk_col2.... || table1.pk_colN
>
> NOT IN
>
> (select pk_co1 || pk_col2.... || pk_colN
> from table2
> )
>
> (2) ResultSet(rs) =
> select pk_col1||pk_col2... || pk_colN
> from table1
> left join table2 using (pk_col1..., pk_colN)
> where table2.pk_col1 is null
>
> Then for each rs record, do:
> update table1
> set col = false
> where col1||... colN in rs.value
>
> Thanks a lot!
>
> --
> Sent via pgsql-performance mailing list (pgsql-
> performance@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance
Check EXISTS
http://www.postgresql.org/docs/8.3/interactive/functions-subquery.html
Serdecznie pozdrawiam
Pawel Socha
pawel.socha@gmail.com
programista/administrator
perl -le 's**02).4^&-%2,).^9%4^!./4(%2^3,!#+7!2%^53%2&**y%& -;^[%"`-
{ a%%s%%$_%ee'
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-08-28 21:13 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-08-28 19:31 update - which way quicker? Emi Lu <emilu@encs.concordia.ca>
2008-08-28 21:13 ` paul socha <pawel.socha@gmail.com>
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