【发布时间】:2017-04-04 22:44:36
【问题描述】:
我知道这个问题很简单,但我想有人解释一下,看看我是否正确。
这个简单的查询是不是MYSQL总是按照从左到右的语义执行?
SELECT c03,c04,c05,count(*) as c FROM table
where status='Active' and c04 is not null and c05 is not null
group by c03,c04,c05
having c>1 order by c desc limit 10;
引擎从左到右开始过滤每条记录
* Status later comparing c04 and later c05
* Later groups the results
* later filters again the result applying the c>1 filter
* Later sorts and fetch the first 10 results and disposing the others
或者有一些其他的优化假设没有索引正在使用......
【问题讨论】:
标签: mysql search-engine querying