Re: Slow query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Roger Ging <rging(at)paccomsys(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Slow query
Date: 2004-10-22 20:37:14
Message-ID: 18707.1098477434@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Roger Ging <rging(at)paccomsys(dot)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

In response to

  • Slow query at 2004-10-22 19:06:30 from Roger Ging

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2004-10-22 20:45:51 Re: [PATCHES] ARC Memory Usage analysis
Previous Message Jan Wieck 2004-10-22 20:29:20 Re: ARC Memory Usage analysis