I ve already seen some questions regarding this like below MySQL “good” way to insert a row if not found, or update it if it is found
Now i have a summary table which gets updated with the qty every time say a sale occurs. so out of 1000 sales of an item only first time the insert executes and the rest of the times it would be update. My understanding is in Insert on Duplicate Key Update
it tries to insert first and if it fails updates. so all 999 times the insert is not successfull
1) Is there a method to check Update first and if not updated then insert in a single statement?
2) which of the below methods would be desirable considering most of the cases update will be successfull
a) using Insert on Duplicate Key Update
b) Call Update; if no rows affected call insert
Right now i am using the second option(b). performance gain is very important here and also i m testing the first option. ill post the results here once done