Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0TIk7l92290 for ; Tue, 29 Jan 2002 13:46:07 -0500 (EST) (envelope-from reedstrm@rice.edu) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id A1D8568A5C; Tue, 29 Jan 2002 12:46:07 -0600 (CST) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id E7F8668A5A; Tue, 29 Jan 2002 12:46:06 -0600 (CST) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.22 #1 (Debian)) id 16VdGg-0000YX-00; Tue, 29 Jan 2002 12:46:06 -0600 Date: Tue, 29 Jan 2002 12:46:06 -0600 From: "Ross J. Reedstrom" To: "Zhang, Anna" Cc: pgsql-admin@postgresql.org Subject: Re: tuning SQL Message-ID: <20020129184606.GA2068@rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , "Zhang, Anna" , pgsql-admin@postgresql.org References: <5511D658682A7740BA295CCF1E1233A635A840@vsvapostal2.bkup3> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5511D658682A7740BA295CCF1E1233A635A840@vsvapostal2.bkup3> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS snapshot-20010714 X-Archive-Number: 200201/246 X-Sequence-Number: 3127 On Tue, Jan 29, 2002 at 12:23:17PM -0500, 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. So, how long does the just the select take? You might be running into something odd with selecting from and inserting into the same table: I'm not sure of the visibility rules here. You might be better off selecting into a new temp table (see: SELECT INTO) then inserting from that. Ross