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 2000 Forums
 SQL Server Development (2000)
 Interpret Execution Plans

Author  Topic 

chaugner
Starting Member

9 Posts

Posted - 2001-12-14 : 15:30:51
Hey there,

maybe someone can help me. I have a query that I am trying to optimized. In Query Analyser I take the original query and then copy and paste it one more time to modify so I have my original query on top and a second one below that will be optimized. When showing the executing plan the one with less percent (Query Cost) should be faster correct???

Now my problem. Consider this scenario.

Query - 6 Seconds - 80%
Optimzed Query - 1 second - 20%

After looking at the execution plan and seeing the order SQL joins the tables I forced SQL to use my order which caused the Query to go down to 1 second :) ... however now my problem. After looking at the execution plan I was amazed ...

Query (with forced join) - 1 second - 99.99%
Optimized Query (without forced join) - 1 second - 0.01%

My only thought is that the statistics are not updated. Anyone out there can explain to me why this is happening.

Thanks,
Chris

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-14 : 19:59:31
Looks like a bug (if they really are both 1 sec).

Try them both in stored procs so they get a cached query plan.
Try the forced join with the unoptimised query too.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

chaugner
Starting Member

9 Posts

Posted - 2001-12-14 : 21:40:06
I played around a little more and took my original query.

Original Query (with forced join) - 1 second - 98.2%
Original Query (without forced join) - 6 seconds - 1.8%

Received that reply on microsoft.public.sqlserver.programming.

DBCC dropcleanbuffers
DBCC freeproccache

Have to try that on monday .. maybe that will help.

Chris

Go to Top of Page
   

- Advertisement -