July 31, 2008 at 12:14 am
Hello Sir,
I have following three quires which generate same results. Please let me know which query is more optimize:
select jq.jobid, jobname from jobqueue jq
inner join taskqueue tq on jq.jobid = tq.jobid
where tq.taskid = 100
select jq.jobid, jobname from jobqueue jq, taskqueue tq
where jq.jobid = tq.jobid and tq.taskid = 100
select jobid, jobname from jobqueue where jobid in(
select jobid from taskqueue where taskid = 100)
Thanks in advance 🙂
Paresh
July 31, 2008 at 2:07 am
Run them all and see which is faster.
The 1st and 2nd should be identical. The explicit joins are preferred over the joins in the where clause for readability at the very least.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 31, 2008 at 5:30 am
And just like your last post, take a look at the execution plans that will tell you a lot of what you need to know for making these sorts of choices. I also agree with Gail, the first choice has the cleaner syntax for readability and maintenance, even if it doesn't affect performance.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply