Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

What is better in term of performance between these 4 queries

$
0
0

1 . Select * from table1 where table1.A in (1,2,3,4,5,6)

2.  Select * from table1 where table1.A in (1,2,3) UNION ALL Select * from table1 where table1.A in (4,5,6)

3.  Select A.* From (Select * from table1 where table1.A in (1,2,3) UNION ALL Select * from table1 where table1.A in (4,5,6)) A

4.  Select A.* From (Select * from table1 where table1.A in (1,2,3) UNION ALL Select * from table1 where table1.A in (1,2,3 ,4,5,6)) A WHERE A.A in (1,2,3)

This is the very simple example  of queries i always use.

I need to know what different  between these 4  in term of performance THANKS.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>