What is Upsert (INSERT ON CONFLICT)?
Upsert (INSERT ON CONFLICT) is a database operation that attempts to insert a new record, but if a conflict occurs on a unique constraint (like a primary key), it updates the existing record instead. In web scraping pipelines, it is the fundamental mechanism for maintaining stateful datasets without duplicating rows or requiring expensive read-before-write checks. Without upserts, incremental scraping jobs quickly degrade into a mess of primary key violations or bloated append-only tables.