sql - What is difference in performance of following 2 queries -


what difference in performance of following 2 queries in sql server 2008

query 1:

select a.id,a.name,b.class,b.std,c.result,d.grade  student inner join classes b on b.id = a.id inner join results c on c.id = a.id inner join grades d on d.name = a.name a.name='test' , a.id=3 

query 2:

select a.id,a.name,b.class,b.std,c.result,d.grade  student  inner join classes b on b.id = a.id , a.name='test' , a.id=3 inner join results c on c.id = a.id inner join grades d on d.name = a.name 

is there best way achieve best perofermance in above 2 queries

you can have 100% guarantee execute same, same plan.

the time matter when splitting and/where clauses in inner join when options force order used.


great performance @ expense of writes, create these indexes:

a (id, name) b (id) includes (class, std) c (id) includes (result) d (name) includes (grade) 

however, still depends on distribution of data , selectivity of indexes whether used. e.g. if grade table contains 5 entries a,b,c,d,e, no index used, scan , buffer table in memory.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -