[英]Mysql update takes a long time on “end” state
I'm having issues with this update query. 我对此更新查询有疑问。 I don't understand why would the "end" state take so long.
我不明白为什么“结束”状态要花这么长时间。
The weird part is that it happens only if I haven't updated the table for a while but after I do, the update queries are super fast. 奇怪的是,只有当我有一段时间没有更新表时,它才会发生,但是在执行更新之后,更新查询会非常快。
I wouldn't care if one update query takes a long time to complete but this query halts every other queries (select/insert/update..) in the server so all of them have to wait until this one is finished. 我不在乎一个更新查询是否需要很长时间才能完成,但是此查询会中止服务器中的所有其他查询(选择/插入/更新..),因此所有这些查询都必须等到此查询完成为止。
I've read a lot through other discussions but all of them were about the "query end" not the "end" state. 我通过其他讨论已经读了很多东西,但所有讨论都是关于“查询结束”而不是“结束”状态的。
This is my latest query that took over 70 seconds: 这是我最新的查询,耗时超过70秒:
UPDATE optimizer_disabled_domains
SET dateChanged = NOW( ) ,
bgProcessID =18,
profile = '1. Default',
creativeIDs = '',
excludeCreativeIDs = '',
emailGroupIDs = '1',
emailDomains = '',
status =1
WHERE id =237
Profiling stats: 分析统计信息:
starting => 0.000053
checking permissions => 0.000010
Opening tables => 0.000029
System lock => 0.000010
init => 0.000042
Updating => 0.000106
end => 0.000009
Waiting for query cache lock => 0.000007
*** end => 69.276521 ***
query end => 0.000203
closing tables => 0.000098
freeing items => 0.000082
logging slow query => 0.000035
logging slow query => 0.000063
cleaning up => 0.000033
Table structure: 表结构:
CREATE TABLE IF NOT EXISTS `optimizer_disabled_domains` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`dateChanged` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`bgProcessID` int(11) NOT NULL,
`profile` varchar(100) NOT NULL DEFAULT '',
`creativeIDs` varchar(255) NOT NULL DEFAULT '',
`excludeCreativeIDs` varchar(255) NOT NULL DEFAULT '',
`emailGroupIDs` varchar(30) NOT NULL DEFAULT '',
`emailDomains` varchar(1000) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `status` (`status`,`bgProcessID`,`profile`,`creativeIDs`,`excludeCreativeIDs`,`emailDomains`(255),`emailGroupIDs`)
) ENGINE=InnoDB
Might be a DNS problem.Add this line in your mysql config and restart 可能是DNS问题。请在您的mysql配置中添加此行,然后重新启动
skip-name-resolve
Also check query cache,if its too large,you may see lock contention issues with a very large cache. 还要检查查询缓存,如果查询缓存太大,则可能会看到缓存很大的锁争用问题。 Link
链接
SHOW VARIABLES LIKE 'query_cache_size';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.