1. Try not to perform functional processing of column names. Instead, it is processed for the following values
For example, where col1 =-5 efficiency is higher than where-col1=5 efficiency
The column values are evaluated because of the subsequent conditions. The optimizer cannot use the index under such conditions
Instead, you have to evaluate all the values before you can compare them.
2. Try to use the same value as the play column to operate
If col1 is a numeric type
So for example where col1 = 2 and where col1= ' 2′
The former is more efficient
Because when comparing characters and numeric types,
The engine needs to convert both to double and then compare.
3. Reduce the use of functions
For example where col1 >= ' 2009-10-26′and col1 <= ' 2009-10-27′
And where DateDiff (Day,col1,getdate ()) =0
The latter is used for function processing. So the index on the col1 can't be used anymore.
4. Try not to use or
General conditions for OR
The optimizer typically uses full table scans