Hi Peter, Thanks for reaching out about this!
On Sat, Sep 27, 2014 at 7:01 PM, Peter Geoghegan <[email protected]> wrote: > Hello, > > I am a PostgreSQL major contributor, currently undertaking development > of a feature sometimes called "UPSERT" for PostgreSQL. > > Jacob Kaplan-Moss is an acquaintance and co-worker, and I know that > it's certainly something that interests him personally - presumably he > has some ideas on how an UPSERT-like feature could be used by Django. > Beyond that, I don't have a good sense of what the level of interest > is in the Django community. I would like to reach out and get feedback > on the syntax that I've proposed on the pgsql-hackers development > list. Certainly, I've put a lot of work into this, and expect to put a > lot more in, so obviously it's important that we not make any missteps > with user-visible semantics. I've used Django a bit in the past, and > my general impression is that the Django development community has > made sound technical decisions, so I'm happy to take your concerns as > representative of the concerns of ORM authors and web frameworks > generally. > > This is a non-standard syntax that is somewhat comparable to MySQL's > INSERT ... ON DUPLICATE KEY UPDATE, while being more flexible and > safe. The SQL standard's MERGE statement is kind of weird, and has a > lot of baggage from trying to serve multiple use-cases, so I avoided > trying to implement that, preferring to focus on something that has > simple atomic insert-or-update semantics - what people seem to > actually want. > > I would like to get a sense of: > > * Would you consider the syntax that I've proposed a good one? > > >From the docs, the syntax looks pretty reasonable, it would be nice to see what some examples look like though. > * If it was available, would you use it in future versions of Django? > Do you think the plugins ecosystem could take advantage of it sooner? > Is the demand there? > > Yes, I think so: https://docs.djangoproject.com/en/dev/ref/models/querysets/#update-or-create exists, but right now it's manually implemented using savepoints (IIRC) -- I think strictly speaking it isn't safe. I think even under MySQL it doesn't use the native support for this feature, having it in PostgreSQL as well would be good motivation. > * What could be better about the feature? > > * How are you using the MySQL feature (INSERT ... ON DUPLICATE KEY > UPDATE), if at all? Do you think it would be useful to have some > degree of compatibility with it? Why or why not? > > I've built html user-facing documentation, which is publicly > available. This page is probably of most interest -- there is > extensive discussion of the new "ON CONFLICT UPDATE/IGNORE" clause: > > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/sql-insert.html > > These may be of some interest (search for "on conflict" to see the new > references to the feature): > > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/transaction-iso.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/ddl-inherit.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/sql-createrule.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/trigger-definition.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/sql-createtrigger.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/index-unique-checks.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/sql-createview.html > > http://postgres-benchmarks.s3-website-us-east-1.amazonaws.com/on-conflict-docs/postgres-fdw.html > > If you feel like actually trying out my patch, you can download the > latest version of the patchset from: > > > http://www.postgresql.org/message-id/CAM3SWZRvkCKc=1Y6_Wn8mk97_Vi8+j-aX-RY-=msrjvu-ec...@mail.gmail.com > > You'll need to build PostgreSQL from the git master branch (which > includes dependencies on things like Flex and Bison), with the patch > set applied. There are guides to doing this on the internet, including > this one: http://www.postgresql.org/docs/devel/static/sourcerepo.html > > Thanks! > -- > Peter Geoghegan > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CAM3SWZSAAK-nSpBuFDpz5KDGPJxNRAE7OGe2sf30Zu0UYCkwNA%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > Cheers, Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084 -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFRnB2Vp4-UAFTdYTrQzXUD8Uhh9Gu%2BeOLLeQeiSHqvxsCbwJQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
