Answer the question
In order to leave comments, you need to log in
MySQL cost of SELECT, UPDATE, INSERT operations, which is cheaper?
Good afternoon!
There is a task: to add\update data on price zones for goods. The user, working with the table, fills in prices for different zones and then these prices need to be recorded in the database
. The fact is that there are already some records of prices in the database, but some are not. The question arises, how to write data, I see 2 options
1. Make an update and if 0 rows are affected, do insert (if 1 row is affected, then go further)
2. Always select and then, depending on the result, already do update or insert
Tell me how is it better to solve this problem?
Mysql innoDB is used, and yii2 (as far as I remember, it caches requests or something like that, generally does not pull the server every time, or am I mistaken?)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question