SQL WHERE Clause Optimization -
suppose have following 3 types:
- type1
- type2
- type3
from optimization standpoint (ignoring maintainabilty; know first option less break if new type added); more efficient write clause this:
where p.typeid in (type1, type2)
or
where p.typeid <> type3
your second option:
where p.typeid <> type3
will more efficient write, uses fewer characters, unless you're on ipad in case it's quite slow < , > chars!
in terms of execution it'll faster execute. has less work single comparison required, whichever way optimise <> going faster in 2 elements.
Comments
Post a Comment