数据库执行SQL语句时是先执行最后的条件,就是说能把数据减到最少的条件写到最后。
例如:
select * from emp where deptno='10' //如果有10万条
select * from emp where groupid='30' //如果有1000条
select * from emp where deptno='10' and groupid='30' //把grouid写在最后效率会更高,因为先执行最后的,最后的选出1000条中筛选会更快
例如:
select * from emp where deptno='10' //如果有10万条
select * from emp where groupid='30' //如果有1000条
select * from emp where deptno='10' and groupid='30' //把grouid写在最后效率会更高,因为先执行最后的,最后的选出1000条中筛选会更快