question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postgres UPSERT native support

See original GitHub issue

Looks like Postgres recently added UPSERT (9.5alpha is it?). Seems Sequelize handles psql upsert fine presently with its workaround, so obviously no rush.

Me personally (and maybe I need re-architecting), my current project’s most common SQL operation is UPSERT. That operation seems quite slow; this is the resultant SQL which looks like it would be slow:

CREATE OR REPLACE FUNCTION pg_temp.sequelize_upsert() RETURNS integer AS $func$ BEGIN INSERT INTO ... VALUES ...; RETURN 1; EXCEPTION WHEN unique_violation THEN UPDATE ... SET ... WHERE ...; RETURN 2; END; $func$ LANGUAGE plpgsql; SELECT * FROM pg_temp.sequelize_upsert();

So I’d personally upgrade to Postgres 9.5 if native upsert becomes supported in sequelize

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:15
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

22reactions
tsheaffcommented, Nov 1, 2018

This is a really stale issue. Is there any update on this?

11reactions
thynsoncommented, Feb 29, 2016

Well, PostgreSQL 9.5 is released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UPSERT - PostgreSQL wiki
"UPSERT" is a DBMS feature that allows a DML statement's author to atomically either insert a row, or on the basis of the...
Read more >
Upsert in SQL: What is an upsert, and when should you use ...
The UPSERT command doesn't exist in MySQL, but upserts can still be achieved. The best method for implementing an upsert in the current...
Read more >
JPA(Hibernate) and postgres sql batch upsert using nativequery
So my question is in that case of native query insert , can we use manual flushing like em.flush() . Will it work...
Read more >
PostgreSQL — How to UPSERT safely, easily and fast
When you UPSERT data into a table, you update or ignore records that already exist and insert new ones. After reading this article, ......
Read more >
Use of the PostgreSQL Upsert (INSERT ON CONFLICT DO ...
PostgreSQL has supported Rule syntax for a long time. Create a rule with Rule syntax. If the rule exists, update it. Otherwise, insert...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found