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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -