{"type":"rich","version":"1.0","provider_name":"Transistor","provider_url":"https://transistor.fm","author_name":"Postgres FM","title":"Get or Create","html":"<iframe width=\"100%\" height=\"180\" frameborder=\"no\" scrolling=\"no\" seamless src=\"https://share.transistor.fm/e/2aebbc6b\"></iframe>","width":"100%","height":180,"duration":3019,"description":"Michael and Nikolay are joined by Haki Benita, a technical lead and database enthusiast who writes an excellent blog and gives popular talks and training sessions too, to discuss the surprisingly complex topic of trying to implement “get or create” in PostgreSQL — handling issues around idempotency, concurrency, and bloat.\n \nHere are some links to things they mentioned:\nHaki Benita https://hakibenita.com \nHow to Get or Create in PostgreSQL (blog post by Haki) https://hakibenita.com/postgresql-get-or-create \n\"Find-or-insert\" using a single query (how-to guide by Nikolay) https://gitlab.com/postgres-ai/postgresql-consulting/postgres-howtos/-/blob/main/0036_find-or-insert_using_a_single_query.md?ref_type=heads \nIs SELECT or INSERT in a function prone to race conditions? (Answer by Erwin Brandstetter)  https://stackoverflow.com/questions/15939902/is-select-or-insert-in-a-function-prone-to-race-conditions/15950324#15950324 \nget_or_create() in Django https://docs.djangoproject.com/en/5.1/ref/models/querysets/#get-or-create \nSubtransactions Considered Harmful (blog post by Nikolay) https://postgres.ai/blog/20210831-postgresql-subtransactions-considered-harmful \nMERGE (Postgres documentation) https://www.postgresql.org/docs/current/sql-merge.html\nHidden dangers of duplicate key violations in PostgreSQL and how to avoid them (blog post by Divya Sharma and Shawn McCoy from the RDS team) https://aws.amazon.com/blogs/database/hidden-dangers-of-duplicate-key-violations-in-postgresql-and-how-to-avoid-them/ \nOne, Two, Skip a Few... (blog post by Pete Hamilton from Incident) https://incident.io/blog/one-two-skip-a-few \n\n~~~\nWhat did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!\n\n~~~\nPostgres FM is produced by:\nMichael Christofides, founder of pgMustard\nNikolay Samokhvalov, founder of Postgres.ai\n\nWith special thanks to:\nJessie Draws for the elephant artwork ","thumbnail_url":"https://img.transistorcdn.com/NFbJlGhGV5mzIU1kM0iZ823A69pjZUNX40LszVO5LKI/rs:fill:0:0:1/w:400/h:400/q:60/mb:500000/aHR0cHM6Ly9pbWct/dXBsb2FkLXByb2R1/Y3Rpb24udHJhbnNp/c3Rvci5mbS9zaG93/LzMyMTQ3LzE3MTA3/OTEzODMtYXJ0d29y/ay5qcGc.webp","thumbnail_width":300,"thumbnail_height":300}