[英]mysql really simple queries took long time
I give you samples from slow-query-log. 我给你的样本来自慢查询日志。
mysql version:5.6.14, 8gb server 6gb free memory, innodb tables mysql版本:5.6.14,8gb服务器6gb可用内存,innodb表
for example: id is primary key when I type this query in phpmyadmin is very fast but its still in my slow query log 例如:当我在phpmyadmin中输入此查询时,id是主键,但是它仍然在我的慢查询日志中
# Query_time: 3.226675 Lock_time: 0.000046 Rows_sent: 0 Rows_examined: 1
SET timestamp=1385980918;
update `rsslists` set `lastTimeRead` = '1385980913', `total` = '66502', `quality` = '0.028284863613124' where `id` = '146';
or this query: 或此查询:
# Query_time: 2.284815 Lock_time: 0.000047 Rows_sent: 0 Rows_examined: 0
SET timestamp=1385980935;
select * from `articles` where `guid` = '1.2180130' limit 1;
explain: 说明:
'guid' is index really simple queries I have no ideas why they taking so long time sometimes 'guid'是索引非常简单的查询,我不知道为什么有时会花费这么长时间
Follow the below key points to optimize the query. 请遵循以下要点来优化查询。
If these tables are huge and have multiple indexes, the insert can be quite slow. 如果这些表很大并且有多个索引,则插入可能会很慢。 You should log all your queries and see how other inserts perform.
您应该记录所有查询,并查看其他插入的执行情况。
As for the select, there should be an index on guid, otherwise it will be slow if it is a large table. 至于选择,应该在guid上有一个索引,否则,如果它是一个大表,它将很慢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.