Home  >  Article  >  Database  >  MySQLSQL优化:碍手碍脚的索引_MySQL

MySQLSQL优化:碍手碍脚的索引_MySQL

WBOY
WBOYOriginal
2016-06-01 13:17:36930browse

该篇是SQL优化的第4篇。

这里主要表达我的一个观点是:不该存在的索引就该干掉,留着碍事

在2014-3-12 15:39:01 -- 15:55:00这段时间内,在某个业务系统我们发现2个问题:

这种现象在数据库中实际也是很常见,就是某个慢查询,始作俑者,执行特马慢,把后面本该很快的查询给堵住,导致系列长查询出现

经诊断,我们发现某张表里存在dateline索引,该索引会让MySQL优化器选择错了执行计划,导致后续大量SQL拥堵,大概有5000条Query相互堵住

如果不走dateline索引,效果很好,下面对比:

1. 执行计划对比

2. 执行时间对比:

因此,我们给开发童鞋的反馈是,卡擦掉dateline索引

起初我们并不知道该索引是否还提供给其他Query使用,所以胆战心惊害怕会引起其他查询变慢

不过经过这段时间的观察,实际上,并没有其他查询在使用这条索引

索引是好东西,但不要贪哦

 Good Luck!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn