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 BD76652C55 for ; Sun, 7 Aug 2005 23:09:12 -0300 (ADT) 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 87512-05 for ; Mon, 8 Aug 2005 02:09:07 +0000 (GMT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by svr1.postgresql.org (Postfix) with ESMTP id 6052152C47 for ; Sun, 7 Aug 2005 23:09:06 -0300 (ADT) Received: from [127.0.0.1] (c-24-4-66-2.hsd1.ca.comcast.net[24.4.66.2]) by comcast.net (sccrmhc11) with ESMTP id <200508080209060110017uqse>; Mon, 8 Aug 2005 02:09:10 +0000 Message-ID: <42F6BEC0.9090504@comcast.net> Date: Sun, 07 Aug 2005 19:09:04 -0700 From: Patrick Hatcher User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow update statement References: <42F4B812.7070501@comcast.net> <17916.1123337563@sss.pgh.pa.us> In-Reply-To: <17916.1123337563@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.943 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: * X-Archive-Number: 200508/58 X-Sequence-Number: 13805 Sorry went out of town for the weekend. The update did occur, but I have no idea when it finished. Here's the actual query and the explain Update: cdm.bcp_ddw_ck_cus = 12.7 M cdm.cdm_ddw_customer = 12.8M explain update cdm.cdm_ddw_customer set indiv_fkey = b.indiv_fkey from cdm.bcp_ddw_ck_cus b where cdm.cdm_ddw_customer.cus_nbr = b.cus_num; Here's the table layout. It's the first time I noticed this, but there is a PK on the cus_nbr and an index. Does really need to be both and could this be causing the issue? I thought that if a primary key was designated, it was automatically indexed.: CREATE TABLE cdm.cdm_ddw_customer ( cus_nbr int8 NOT NULL, ph_home int8, ph_day int8, email_adr varchar(255), name_prefix varchar(5), name_first varchar(20), name_middle varchar(20), name_last varchar(30), name_suffix varchar(5), addr1 varchar(40), addr2 varchar(40), addr3 varchar(40), city varchar(25), state varchar(7), zip varchar(10), country varchar(16), gender varchar(1), lst_dte date, add_dte date, reg_id int4, indiv_fkey int8, CONSTRAINT ddwcus_pk PRIMARY KEY (cus_nbr) ) WITH OIDS; CREATE INDEX cdm_ddwcust_id_idx ON cdm.cdm_ddw_customer USING btree (cus_nbr); CREATE TABLE cdm.bcp_ddw_ck_cus ( cus_num int8, indiv_fkey int8 NOT NULL ) WITHOUT OIDS; Tom Lane wrote: >Patrick Hatcher writes: > > >>I'm running an update statement on about 12 million records using the >>following query: >> >> > > > >>Update table_A >>set F1 = b.new_data >>from table_B b >>where b.keyfield = table_A.keyfield >> >> > >What does EXPLAIN show for this? > >Do you have any foreign key references to table_A from elsewhere? > > regards, tom lane > > >