Re: Duplicate key insert question

From: "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Duplicate key insert question
Date: 2003-07-02 07:30:44
Message-ID: 3F02D77C.3125.4B161F4@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2 Jul 2003 at 16:19, Jean-Christian Imbeault wrote:
> I just want two things from any valid solution:
>
> 1- if there is an insert and there is not row with the new insert's
> primary key then the insert is made. If there are multiple inserts one
> succeeds. i.e. No valid inserts will be 'lost'.

With postgresql, if you use transacations, no valid inserts are ever lost
unless there is a deadlock.
>
> 2- reduce the number of error messages logged as a result of
> 'collisions' between two backends trying to insert duplicate primary key
> rows.

Log of what? Postgresql will log all the errors. If you don't want to see them,
tune the logging option.

If your code is doing any checking for return value etc., check if it is a
duplicate message and discard it. That way you can minimize your application
logging.

Otherwise use select/insert behaviour referred earlier.

Besides if you are going to insert a duplicate rarely, why worry so much about
performance? And if your dulicates are bit too frequent for comfort, you might
have some more issues w.r.t database table design to look at.

Bye
Shridhar

--
And 1.1.81 is officially BugFree(tm), so if you receive any bug-reportson it,
you know they are just evil lies."(By Linus Torvalds,
Linus(dot)Torvalds(at)cs(dot)helsinki(dot)fi)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2003-07-02 07:32:38 Vacuuming specific schemas..
Previous Message Jean-Christian Imbeault 2003-07-02 07:19:10 Re: Duplicate key insert question