By 老猫 | 3月 4, 2011 - 5:02 下午 - Posted in Teradata
第一个原则:在 where 子句中应该把最具限制性的条件放在最前面.
– 在下面的两条 select 语句中:
select * from table 1 where col1 <= 10000 and col1 >=0; select * from table 1 where col1 >=0 and col1 <= 10000;
-如果数据表中的数据 col1 都>=0 ,则第一条语句要比第二条select 语句效率高的多,因为第二条语句的第一个条件耗费了大量的系统资源.
第二个原则: where 子句中字段顺序应和索引中字段顺序一致.