Re: How could this SQL be optimized?
Posted by:
feng guo
Date: May 30, 2014 02:46AM
Øystein Grøvlen Wrote:
-------------------------------------------------------
> Hi,
>
> I do not think these statements are equivalent.
> Are you optimizing for speed or statement
> complexity? If the former, and assuming that
> ORDERID values are unique, I suggest the
> following:
>
> SELECT
> ID,WAYBILL_NO,EXP_TYPE,PKG_QTY,EXPRESS_CONTENT_COD
> E,EFFECTIVE_TYPE_CODE
> FROM T_EXP_OP
> WHERE AUX_OP_CODE NOT IN ('NEW','UPDATE','DELETE')
> OR NOT ((OP_CODE IN (176, 162, 171, 131, 136) AND
> EXP_TYPE IN ('10', '20', '30')) OR (OP_CODE IN
> (191, 121) AND EXP_TYPE IN ('10', '20')) OR
> (OP_CODE IN (181, 111)AND EXP_TYPE = '10'));
Thanks,my origin thinking is same with yours,but that time I wasn't confident,especially after someone gives me such 'answer' above~