ALL, I have a DB with some data. I also have a C++ application that communicates with the DB.
Which scenario is more efficient?
Scenario 1:
Scenario 2:
I'm inclined to say scenario 2.
Its a question of which is efficient and transactionally sound. Deleting an existing object to perform an update is not transactionally sound. Updates exist to update existing entities in the database. If you are using synthetic keys you cant use this approach at all.
In most system, a refetch (to at least check if the object your about to commit has been modified since you requested it from the database) is mandatory.
Step 4 should read, refetch the object from the database to ensure it hasnt changed, then commit update or rollback.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.