Re: Slow query - Mailing list pgsql-performance

From Tom Lane
Subject Re: Slow query
Date
Msg-id 18707.1098477434@sss.pgh.pa.us
Whole thread Raw
In response to Slow query  (Roger Ging <rging@paccomsys.com>)
Responses Re: Slow query
List pgsql-performance
Roger Ging <rging@paccomsys.com> writes:
> update source_song_title set
> source_song_title_id = nextval('source_song_title_seq')
> ,licensing_match_order = (select licensing_match_order from
> source_system where source_system_id = ss.source_system_id)
> ,affiliation_match_order = (select affiliation_match_order from
> source_system where source_system_id = ss.source_system_id)
> ,title = st.title
> from source_song_title sst
> join source_song ss on ss.source_song_id = sst.source_song_id
> join source_title st on st.title_id = sst.title_id
> where source_song_title.source_song_id = sst.source_song_id;

Why is "source_song_title sst" in there?  To the extent that
source_song_id is not unique, you are multiply updating rows
because of the self-join.

            regards, tom lane

pgsql-performance by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Performance Anomalies in 7.4.5
Next
From: "Matthew T. O'Connor"
Date:
Subject: Re: Performance Anomalies in 7.4.5