我有一个网站和一个拥有 500 万行的数据库,它运行得非常棒。但是,我每小时运行一次清理 cronjob,将旧数据放入“日志”表并删除旧数据,此时服务器响应非常慢。是否可以通过 PHP 或 MySQL 降低该作业的优先级?
最佳答案
我认为清理中最繁重的任务是您可以使用 LOW_PRIORITY 的 DELETE 操作。
从 MySql 中删除语法 manual page :
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name ...
和描述:
If you specify LOW_PRIORITY, the server delays execution of the DELETE until no other clients are reading from the table. This affects only storage engines that use only table-level locking (such as MyISAM, MEMORY, and MERGE).
关于php - PHP 或 MySQL 中的低优先级请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7743499/