Introduce upsert batching functionality in the database layer.