You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).type: refactorDEPRECATED: replace with the "meta" issue type
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
Reacted by Michael Haselton, Idris Mokhtarzada, Daiwei Lu, Joey Cozza, Gábor Soós, swarthy, Florian P. Nierhaus, Jan Beletskiy, Leonardo Donelli, Pedro Machado and 6 more
@mickhansen All the query work regarding version detection is actually already in place - As far as I can see we just need to actually select the verison, and find a good datastructure for storing which features are supported by what versions
Any updates on this @mickhansen ? Our team is currently looking at how to optimize our upserts, as the native PostgreSQL 9.5 upsert is much faster. We'd strongly prefer not to re-implement upsert ourselves as a native query.
@tsheaff No one is working on it, but version detection is in place so it should not be a lot of work (alternative syntax based on version detected). We have support for testing against 9.5 aswell.
This is a really stale issue. Is there any update on this?
Reacted by zhvankoi, Wilhelm R., Nyx, Hrvoje Husnjak, Jan Beletskiy, Sergey Yarotskiy, Kevin Montag, sebastian krämer, Benoit MERIAUX, Ryan Hoffman and 12 more
dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).type: refactorDEPRECATED: replace with the "meta" issue type
Activity
mickhansen commentedon Jul 16, 2015
We still need a proper way to detect features based on the server version, but yeah ideally we'd want to use the built in UPSERT when possible.
lefnire commentedon Jul 16, 2015
Possible sloppy short-term solution: pass version constructor options? Eg:
new Sequelize('database', 'username', 'password', {..., version:'9.5'})janmeier commentedon Jul 17, 2015
@mickhansen All the query work regarding version detection is actually already in place - As far as I can see we just need to actually select the verison, and find a good datastructure for storing which features are supported by what versions
janmeier commentedon Jul 17, 2015
One problem though is that pg 9.5 is not supported by travis - and probably won't be before its officially releasesd
lorenz commentedon Aug 29, 2015
+1
thynson commentedon Feb 29, 2016
Well, PostgreSQL 9.5 is released.
ncwhale commentedon May 27, 2016
Sometimes, just need update one signal col when insert failed, right now I'll do it like this:
but with pg 9.5 , how about add a suger option when insert fail? like this
It most like the upsert on another way, but with other db also can also use it as is.(by add a catch and do the sub query.)
tsheaff commentedon Nov 28, 2016
Any updates on this @mickhansen ? Our team is currently looking at how to optimize our upserts, as the native PostgreSQL 9.5 upsert is much faster. We'd strongly prefer not to re-implement upsert ourselves as a native query.
mickhansen commentedon Nov 28, 2016
@tsheaff No one is working on it, but version detection is in place so it should not be a lot of work (alternative syntax based on version detected). We have support for testing against 9.5 aswell.
tsheaff commentedon Nov 28, 2016
Awesome thanks for quick reply @mickhansen Any rough estimate on timeline?
felixfbecker commentedon Nov 28, 2016
As he said, noone is working on it. PRs welcome :)
tsheaff commentedon Nov 28, 2016
PR is already out @felixfbecker here: #6325
Waiting on code review and merge
Support INSERT... ON CONFLICT for upserts
7 remaining items
tsheaff commentedon Nov 1, 2018
This is a really stale issue. Is there any update on this?