推迟MySQL中的频繁更新 [英] Deferring frequent updates in MySQL
问题描述
我经常对用户表进行更新,该表只是设置了用户的上次查看时间,我想知道是否存在一种简单的方法可以将其推迟到很短的超时(5分钟或5分钟)后再将它们分组为一个查询所以).这样可以大大减少对我的用户数据库的查询.
I have frequent updates to a user table that simply sets the last seen time of a user, and I was wondering whether there is a simple way to defer them and group them into a single query after a short timeout (5 minutes or so). This would reduce queries on my user database quite a lot.
推荐答案
如果您执行UPDATE LOW_PRIORITY table ...
,则将确保它仅在不执行其他任何操作时才执行更新.除此之外,我认为MySQL内没有太多选择.
If you do a UPDATE LOW_PRIORITY table ...
you will make sure it will only execute your update when it's not doing anything else. Besides that I don't think there are much options inside MySQL.
而且,它现在是否会引起问题,还是您只是在优化没有问题的内容?就个人而言,如果我要像这样批量更新,我只需将所有ID插入memcached中,并使用cronjob每5分钟更新一次.
Also, is it causing problems now or are you simply optimizing something that isn't a problem? Personally, if I would batch updates like these I would simply insert all the IDs in memcached and use a cronjob to update every 5 minutes.
这篇关于推迟MySQL中的频繁更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!