From: Ross J. Reedstrom <reedstrm@rice.edu>
To: Zhang, Anna <azhang@verisign.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: tuning SQL
Date: Tue, 29 Jan 2002 12:46:06 -0600
Message-ID: <20020129184606.GA2068@rice.edu> (raw)
In-Reply-To: <5511D658682A7740BA295CCF1E1233A635A840@vsvapostal2.bkup3>
References: <5511D658682A7740BA295CCF1E1233A635A840@vsvapostal2.bkup3>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: reedstrm@rice.edu, azhang@verisign.com
Subject: Re: tuning SQL
In-Reply-To: <20020129184606.GA2068@rice.edu>
References: <5511D658682A7740BA295CCF1E1233A635A840@vsvapostal2.bkup3> <20020129184606.GA2068@rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox