首先看代码
--最优 select 一堆字段,to_char(dbirthday,'yyyy-mm-dd hh:mi:ss') as dbirthday,字段,to_char(dupdatetime,'yyyy-mm-dd hh:mi:ss') as updatetime,还有一堆字段 from table where (dupdatetime>to_date('1900','yyyy')) order by dupdatetime DESC,istate asc nulls last; --渣渣 select 一堆字段,to_char(dbirthday,'yyyy-mm-dd hh:mi:ss') as dbirthday,字段,to_char(dupdatetime,'yyyy-mm-dd hh:mi:ss') as dupdatetime,还有一堆字段 from table where (dupdatetime>to_date('1900','yyyy')) order by dupdatetime DESC,istate asc nulls last; --渣渣 select 一堆字段,to_char(dbirthday,'yyyy-mm-dd hh:mi:ss') as dbirthday,字段,to_char(dupdatetime,'yyyy-mm-dd hh:mi:ss') as dupdatetime,还有一堆字段 from table order by dupdatetime DESC nulls last;
注意上面三个SQL,第三个因为没有where条件,order by 造成效率低下。
第一个和第二个SQL的差距就一个字母,dupdatetime字段在oracle下面,转换格式时,别名使用和原字段名相同的名称,会造成效率低下。