Upserting
Upserting is a database operation that combines inserting a new row with updating an existing one. If a row already exists that matches a unique constraint or primary key, the database updates the specified fields; otherwise it inserts a new row. The term is a portmanteau of insert and update and is widely supported in modern relational and document-oriented databases.
Vertical variants exist across systems. In PostgreSQL, the common pattern is INSERT ... ON CONFLICT DO UPDATE;
Upserts are designed to be atomic, preventing race conditions where two processes insert the same row simultaneously.
Common use cases include data synchronization, feed processing, and maintaining slowly changing dimensions, where the same