加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码门户网 (https://www.92codes.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

MySQL查询速度慢…有时候

发布时间:2021-05-25 07:53:30 所属栏目:MySql教程 来源:网络整理
导读:副标题#e# 我有一个查询,用于我们的报告系统,有时运行速度超过一秒,其他时间需要1到10分钟才能运行. 这是慢查询日志中的条目: # Query_time: 543 Lock_time: 0 Rows_sent: 0 Rows_examined: 124948974use statsdb;SELECT count(distinct Visits.visitorid)

+----+-------------+---------+------+---------------------------+---------------------+---------+------------------+------+--------------------------------------+
| id | select_type | table   | type | possible_keys             | key                 | key_len | ref              | rows | Extra                                |
+----+-------------+---------+------+---------------------------+---------------------+---------+------------------+------+--------------------------------------+
|  1 | SIMPLE      | v       | ref  | PRIMARY,cand_visitor_omit | cand_visitor_omit   | 4       | const            |    1 | Using where                          |
|  1 | SIMPLE      | current | ref  | visitorid_visittime       | visitorid_visittime | 8       | test.v.visitorid |    2 | Using where; Using index             |
|  1 | SIMPLE      | earlier | ref  | visitorid_visittime       | visitorid_visittime | 8       | test.v.visitorid |    2 | Using where; Using index; Not exists |
+----+-------------+---------+------+---------------------------+---------------------+---------+------------------+------+--------------------------------------+

以这种方式更改索引也会使访问者(visitorid)上的其他单列索引变得多余,因此您可以删除该索引.

(编辑:源码门户网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!