Answer the question
In order to leave comments, you need to log in
How less resource-intensive to implement an addition or update?
Given : Table with columns id, user_id, meta_key, meta_val
Task : There was a need to make a multiple addition of records to the table with user_id==3, but if there is a row with equal meta_key, then it needs to be updated.
Suggestion 1 : Do this in several queries (1st: take all non-empty rows by user_id, 2nd: update them if they have been replaced, 3rd: add new rows if necessary)
Suggestion 2 : Make a procedure in which to pass mutable values. In procedure to compare and there to solve update or insert.
Thank you.
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