Received: from jupiter.hub.org (jupiter.hub.org [64.49.215.5]) by postgresql.org (Postfix) with ESMTP id 6C12B475892 for ; Tue, 12 Mar 2002 02:05:48 -0500 (EST) Received: (from news@localhost) by jupiter.hub.org (8.11.6/8.11.6) id g2C6eQX46589 for pgsql-admin@postgresql.org; Tue, 12 Mar 2002 00:40:26 -0600 (CST) (envelope-from news) From: rhairgroveNoSpam@Pleasebigfoot.com (Bob Hairgrove) X-Newsgroups: comp.databases.postgresql.admin Subject: Re: tuning SQL Message-ID: <3c8da273.40203589@news.ch.kpnqwest.net> References: <5511D658682A7740BA295CCF1E1233A635A840@vsvapostal2.bkup3> X-Newsreader: Forte Free Agent 1.21/32.243 Lines: 30 Date: Tue, 12 Mar 2002 06:40:25 GMT X-Complaints-To: news@kpnqwest.ch Organization: KPNQwest customer news service To: pgsql-admin@postgresql.org X-Archive-Number: 200203/179 X-Sequence-Number: 3713 On Tue, 29 Jan 2002 17:45:34 +0000 (UTC), azhang@verisign.com ("Zhang, Anna") wrote: >Thanks Peter Darley, Ross J. Reedstrom and Tom lane!! >How silly am I! Your messages reminds me. Actually I want to insert rows of >contact_discard table which are not exists in contact table to contact table >(some duplicates in two tables), first I run > >insert into contact >select * from contact_discard a >where not exists ( select 1 from contact b where b.contacthandle = >a.contacthandle); > >It seems takes forever, I killed it after hours(note: contact table has 4 >indexes). Then I tried to figure out how many rows that are not duplicated. >Now my problem turns to insert performance, in oracle it takes only a few >minues. > >Thanks! > >Anna Zhang > With millions of rows, you also might want to create a temporary (real) table with just the select statement, then drop ALL the indexes on contact, do the update, then recreate the indexes. Bob Hairgrove rhairgroveNoSpam@Pleasebigfoot.com