Upsert
An upsert is a data-modification operation that updates a matching record or resource, or inserts it when no match exists.
Microservices Patterns, Second Edition
A database operation that inserts a record if it is absent and updates it otherwise.
- How it is used
- Handles uncertain record existence in CQRS view repositories when event handlers apply create or update events.
- How deep it goes
- Defines insert-if-absent and update-if-present behavior, and motivates it with out-of-order events; leaves concurrency and duplicate handling to further processing.
- Examples
- Uses create and update handlers encountering records already present or not yet created because related events arrive out of order.
- What you can do after
- Apply upserts in create and update methods to insert absent records or update existing ones.
Read how Microservices Patterns, Second Edition explains upsert →
Architecting an Apache Iceberg Lakehouse
An upsert operation inserts records that are absent and updates records that already exist according to a matching key or condition.
- How it is used
- Supports transactional ingestion, reconciliation, slowly changing dimensions, late-arriving data, and downstream synchronization.
- How deep it goes
- Explains matching, snapshot commits, engine responsibilities, and operational tradeoffs without detailing the Iceberg specification.
- Examples
- Uses a Spark MERGE between a staging table and target, matching records by identifier before updating or inserting.
- What you can do after
- Apply it via Apache Spark to reconcile staging data with Iceberg tables through conditional updates and inserts.
Read how Architecting an Apache Iceberg Lakehouse explains upsert →
ScyllaDB in Action
An upsert is a write operation that combines insert and update behavior by creating missing data or modifying existing data.
- How it is used
- Combines ScyllaDB inserts and updates into fast writes for restaurant-review rows.
- How deep it goes
- Explains syntax, partition-key filtering, preserved columns, and deferred deeper treatment of row liveness.
- Examples
- Uses an Ernie’s Eats fried-chicken review, UPDATE and INSERT statements, and a SELECT result.
- What you can do after
- Apply upserts with CQL UPDATE statements while preserving unchanged columns and targeting the partition key.
Akka in Action, Second Edition
An upsert is a database operation that inserts a record when no matching record exists and updates the matching record otherwise.
- How it is used
- Stores projected aggregates in a separate database while decoupling journal reads from writes.
- How deep it goes
- Defines insert-versus-update behavior and demonstrates transactional SQL, stopping short of database-library details.
- Examples
- Uses a cargo-per-container projection that creates a count and increments it for later CargoAdded events.
- What you can do after
- Apply it via ScalikeJDBC to create or update aggregate rows inside a projection transaction.
Also covered in
- Data-Oriented Programming in JavaIn early access (MEAP)
- Clojure: The Essential Reference
- Grokking Software ArchitectureIn early access (MEAP)
- PostgreSQL Mistakes and How to Avoid Them
- Kafka for Architects
- Elasticsearch in Action, Second Edition
- Java Persistence with Spring Data and Hibernate epub
- The Design of Web APIs, Second Edition
- MongoDB 8.0 in Action, Third Edition
What to know first
- topicA topic is a named channel or category that groups messages or records for publication and delivery to interested consumers.
- SQLSQL is a standardized declarative language for defining, querying, and manipulating data in relational database systems.
Related concepts
- Documentproduces · A document is a discrete information-bearing item or structured representation of content, often including text, fields, or associated metadata.
- ON CONFLICT clauseimplemented by · An ON CONFLICT clause specifies the action an SQL insert takes when it violates a uniqueness or exclusion constraint.
- database updateimplemented by · A database update is an operation that modifies existing records, rows, documents, or other stored data according to specified criteria.
- updateOne()configures · updateOne() is a MongoDB update method that modifies the first document matching a filter, or inserts a document when upsert is enabled and no match exists.
Questions about upsert
What is upsert?
An upsert is a data-modification operation that updates a matching record or resource, or inserts it when no match exists.
Which Manning books explain upsert?
Microservices Patterns, Second Edition, Architecting an Apache Iceberg Lakehouse, ScyllaDB in Action and Akka in Action, Second Edition.
What should I know before learning upsert?
Manning books that teach upsert usually introduce topic and SQL first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



