Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
amsqlguy
Yak Posting Veteran
89 Posts |
Posted - 2008-11-03 : 13:57:54
|
Guys,I have an employee table in which each employee is categorized by employee type (up to 100 types). Currently I have 50 mill rows in the table I run the following query against the database.SELECT FNAME, MNAME, LNAME, SSN, EMPDATE, DOB, SEX, SALFROM EMPLOYEE WHERE EMP_TYP IN (1, 2, 4, ....) - UPTO 70 EMP TYPES IN "IN CLAUSE"If I would change the above query to do not "in clause" SELECT FNAME, MNAME, LNAME, SSN, EMPDATE, DOB, SEX, SALFROM EMPLOYEE WHERE EMP_TYP not IN (11, 23, 49, ....) - UPTO 30 EMP TYPES IN "IN CLAUSE"I did not notice any big difference in the performance. Is there any difference between how the SQL engine treats "IN CLAUSE" VS "CLAUSE" shouldnt the second query be faster.Any suggestions and inputs would helpThanks |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-11-03 : 22:28:07
|
Looks like you are fetching million of records. |
 |
|
saurabhsrivastava
Posting Yak Master
216 Posts |
Posted - 2008-11-03 : 23:01:27
|
Did you look at execution plans of both queries to find out index usage? You may be better able to tune it then. |
 |
|
|
|
|
|
|