I have a table with hundreds of thousands of data. Every time an event is triggered, all tables will be queried. If the conditions are met (most of them will be met), a certain field of the table data will be modified (each modified data They are all different) Please tell me how to do it most efficiently because I am a newbie and don’t know much about it. Thank you very much
There is a query first, so the query conditions must make the created index effective.
For the second batch of modifications, the modified index must take effect. But if most of the data meets your conditions, the index will be prone to failure, so it is recommended to obtain all matching id values and update the data through the id values
If an event causes hundreds of thousands of UPDATEs:
Check whether there is a design problem;
If the design is correct, try to add a cache layer such as redis, and then use asynchronous methods such as message queues to update the database table;