【发布时间】:2016-12-28 07:04:28
【问题描述】:
我对 where 子句的排序有疑问。
我从其他问题中看到 where 子句的顺序不会影响 sql 查询的性能,但是我的查询性能会随着我更改顺序而改变。
select sql_no_cache idx
from rr
where (timestamp >= '2016-11-28' and timestamp <= '2016-12-28')
and ((select name from xx where midx=rr.midx) like 'test'
比
快select sql_no_cache idx
from rr
where ((select name from xx where midx=rr.midx) like 'test'
and (timestamp >= '2016-11-28' and timestamp <= '2016-12-28')
表 rr 在 'idx'、'midx' 和 'timestamp' 上有索引
知道为什么吗??
【问题讨论】:
-
因为查询优化器并不完美。