From: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | Dan Harris <fbsd(at)drivefaster(dot)net> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: faster INSERT with possible pre-existing row? |
Date: | 2005-07-27 01:55:47 |
Message-ID: | 42E6E9A3.4000400@familyhealth.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Insert into a temp table then use INSERT INTO...SELECT FROM to insert
all rows into the proper table that don't have a relationship.
Chris
Dan Harris wrote:
> I am working on a process that will be inserting tens of million rows
> and need this to be as quick as possible.
>
> The catch is that for each row I could potentially insert, I need to
> look and see if the relationship is already there to prevent multiple
> entries. Currently I am doing a SELECT before doing the INSERT, but I
> recognize the speed penalty in doing to operations. I wonder if there
> is some way I can say "insert this record, only if it doesn't exist
> already". To see if it exists, I would need to compare 3 fields
> instead of just enforcing a primary key.
>
> Even if this could be a small increase per record, even a few percent
> faster compounded over the whole load could be a significant reduction.
>
> Thanks for any ideas you might have.
>
> -Dan
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Kings-Lynne | 2005-07-27 02:02:21 | Re: [IMPORTANT] - My application performance |
Previous Message | Mark Lewis | 2005-07-26 22:29:23 | Re: faster INSERT with possible pre-existing row? |