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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Huh?? 0 seconds vs 45 seconds??

Author  Topic 

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2010-05-07 : 14:48:48
This makes no sense to me.

I have a query that when I do

Select *
from
tbl1 a
inner join
...
(About 10 table joins)

it runs in 0 seconds (Very good performance)

but when I do

select a.col1
,b.col2
,c.col2
...
from
Myquery

it takes 45 seconds???

The select list is doing nothing besides displaying the same selected columns as when I do "Select *"...

Any ideas on why a select list that has NO formula's or subqueries would effect the execution plan?

Thanks!


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-07 : 16:14:15
If the execution plan is bad, then you should consider clearing the procedure cache. If that doesn't work, then you may need to add index hints to help the query optimizer pick the correct plan.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-05-08 : 04:18:26
Look at the query plan for both and see if/where they are different?
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2010-05-08 : 06:22:20
Also - when you are comparing the 2 statements - ensure you are applying consistent comparison
http://www.quicksqlserver.com/2010/05/query-baseline-testing.html

Jack Vamvas
--------------------
http://www.ITjobfeed.com
Go to Top of Page
   

- Advertisement -