亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php - mysql update operation is slow, how to solve it
僅有的幸福
僅有的幸福 2017-05-16 13:07:09
0
2
656

The database has an items table, and now we need to update the userid field in it.
The statement is UPDATE items SET userid = xxx WHERE userid = 0 limit 1;
Transactions have been enabled for optimization It’s time, but it still feels too slow. It takes 3 minutes to update 30,000 articles.
Try to create a temp table in the morning, save the userid->items array, and then write a php script to continuously query the temp table, and then operate.
But when multiple scripts are executed like this, only one can survive...and the monitoring effect cannot be achieved.
The current idea is to divide the update operation into deletion and insertion.. Trying now
Also, I would like to ask, if you are developing PHP, which message queue is better to use? I can’t find the documentation for the PHP version of rabbitmq. . .

僅有的幸福
僅有的幸福

reply all(2)
我想大聲告訴你

You can use Replace into instead of update, or you can use insert into...on duplicate key update to update in batches.

In addition, a demo of the Rabbitmq PHP version is attached:
https://github.com/yuansir/ra...

僅有的幸福

Use redis as a queue. This is generally used. Your sql is probably slow because of the limit. Try to take out the IDs of all the data to be updated and then update it. It will be much better

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template