Mysql batch data update and insertion pit

has such a logic, a piece of data, if there is in the database, then update, if it does not exist, then insert. But now there are ten thousand. So how to accomplish the task efficiently?


MySQL has a special syntax INSERT. ON DUPLICATE KEY UPDATE should be the most efficient.
refer to official documentation .

in addition, you have multiple records, so to start a transaction, it is much more efficient to update multiple entries in one transaction than to update one transaction at a time.

Menu