I know they added some alternate form of this, which is just broken in a different way (INSERT and then SELECT on failure), and an actual upsert API
-
-
Replying to @mountain_ghosts
Hey
@sgrif I'm sure you know about these things, would you care to weigh in?2 replies 0 retweets 0 likes -
Replying to @penelope_zone @samphippen and
Literally all I want is find_or_create_by to do an `on duplicate update` in postgres.
1 reply 0 retweets 3 likes -
"find or create" and "create or update" are different operations though
1 reply 0 retweets 1 like -
There’s also create or find by
1 reply 0 retweets 0 likes -
Replying to @penelope_zone @samphippen and
yeah I think that's the thing that does INSERT and then SELECT if that fails
1 reply 0 retweets 0 likes -
yup
1 reply 0 retweets 0 likes -
Replying to @penelope_zone @samphippen and
That also has a race condition where a DELETE can occur between INSERT and SELECT
1 reply 0 retweets 0 likes -
Replying to @jashmatthews @samphippen and
Transaction isolation level serializable is fine until 100,000 people turn up to sign a petition
1 reply 0 retweets 2 likes
Bingo. Every solution has a tradeoff somewhere. Race condition with concurrent deletes is probably the most reasonable (or at least simplest) for most apps.
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.