I have a simple performance related question regarding Equality and Inequality. from the past experience I learnt that any Eq conditions work better and Or conditions cause some perf issues.
When I look at the query plan for both when executed side by side both had a Scan type of EQ
did same query plan. does it make a difference if I have the query formatted like NOT(A=B and C=D)
or Just work with (A <> B or C<> D)
what is the best approach?
Did not think about nulls here, but here is the difference.
SELECT 1 WHERE NOT(2=1 AND NULL=2)
SELECT 1 WHERE NOT(2=1 AND 3=NULL)
SELECT 1 WHERE NOT(2=1 AND NULL=2)
SELECT 1 WHERE NOT(1=1 AND 3=NULL)
SELECT 1 WHERE NOT(NULL=1 AND 2=2)
SELECT 1 WHERE NOT(NULL=null AND 2=2) --Point to note is his one. False, True
SELECT 1 WHERE NOT(1=1 AND 3=3)
SELECT 1 WHERE (2<>1 OR NULL<>2)
SELECT 1 WHERE (2<>1 OR 3<>NULL)
SELECT 1 WHERE (2<>1 OR NULL<>2)
SELECT 1 WHERE (1<>1 OR 3<>NULL)
SELECT 1 WHERE (NULL<>1 OR 2<>2)
SELECT 1 WHERE (NULL<>null or 2=2) --Point to note is his one. True, True
SELECT 1 WHERE (1<>1 OR 3<>3)