X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F00AAEAD7E2 for ; Fri, 22 Oct 2004 21:37:09 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56489-04 for ; Fri, 22 Oct 2004 20:37:09 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3CDFAEAC955 for ; Fri, 22 Oct 2004 21:36:59 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i9MKbEwk018708; Fri, 22 Oct 2004 16:37:14 -0400 (EDT) To: Roger Ging Cc: pgsql-performance@postgresql.org Subject: Re: Slow query In-reply-to: <41795A35.4060802@paccomsys.com> References: <41795A35.4060802@paccomsys.com> Comments: In-reply-to Roger Ging message dated "Fri, 22 Oct 2004 12:06:30 -0700" Date: Fri, 22 Oct 2004 16:37:14 -0400 Message-ID: <18707.1098477434@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/381 X-Sequence-Number: 8857 Roger Ging 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