Re: INSERT ... ON CONFLICT {UPDATE | IGNORE} - Mailing list pgsql-hackers

From Anssi Kääriäinen
Subject Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Date
Msg-id 1418035434.22478.119.camel@TTY32
Whole thread Raw
In response to Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
On Fri, 2014-12-05 at 10:00 -0800, Josh Berkus wrote:
> I thought the point of INSERT ... ON CONFLICT update was so that you
> didn't have to care if it was a new row or not?
> 
> If you do care, it seems like it makes more sense to do your own INSERTs
> and UPDATEs, as Django currently does.

Django tries to update the object if it already exists in the database.
If it doesn't, then Django does an insert. This is suboptimal from
concurrency standpoint, and does two round trips to the database instead
of just one.

For Django, both insert and update are OK when saving an object to the
database, but Django needs to know which one was done.

I too agree that this doesn't need to be handled in the first version of
the patch.
- Anssi




pgsql-hackers by date:

Previous
From: Thomas Reiss
Date:
Subject: Casting issues with domains
Next
From: Craig Ringer
Date:
Subject: Re: [Windows,PATCH] Use faster, higher precision timer API