November 23, 2015 at 12:12 am
HI,
I have question for using 'joins' in sql server. i just want to know that which way would be better with respect to performance in sql server.
Query 1
select * from a inner join b on a.id = b.id
where a.id =1 and a.RNo=@RNo
Query 2
select * from a inner join b on a.id = b.id and a.id =1
where a.RNo=@RNo
I am using this query in SP where in SP i have only 1 parameter named @RNo and 'a.id =1' is fix.
Now my question is does these two queries make any difference.
if yes which way i should write query.
(After writing SP i do Optimizing using Database Tuning Adviser ) is it OK ?
November 23, 2015 at 2:31 am
As written, they're identical. If you were using a LEFT join, they'd have different meanings and different results. Nothing to do with performance.
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
November 23, 2015 at 2:42 am
The first place to look when you're doing performance tuning is the execution plan. If you'd compared the plans for the two queries, you'd have noticed they're identical and therefore there would be no difference in performance.
Be very careful when using DTA, and certainly don't blindly implement all the indexes it suggests.
John
November 23, 2015 at 2:48 am
KcV (11/23/2015)
(After writing SP i do Optimizing using Database Tuning Adviser ) is it OK ?
I am not sure you should completely rely on DTA for performance optimisation that too at SP level . It is better to have design and development standards and practises, and tune the query when it is required.
But using DTA for learning is fine though.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply