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)
 exec sp takes 18min, exec sql takes 1sec?

Author  Topic 

markj11
Starting Member

17 Posts

Posted - 2008-10-15 : 15:45:17
I have a sp that is taking 18 minutes to return 6500 rows. I can take the sql out of the sp and declare/set the parameters and it takes 1 second. I am mainly involved in sql2005 which this sp works fine, so I don't know were to begin with this?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-15 : 15:51:03
you can begin with showing us the sp...

Webfred

Planning replaces chance by mistake
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-15 : 15:52:43
Parameter sniffing?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-15 : 16:09:46
Yes maybe.
We can see if OP shows sp and it's not using local vars.

good night for now!

Webfred

Planning replaces chance by mistake
Go to Top of Page

markj11
Starting Member

17 Posts

Posted - 2008-10-16 : 13:30:55
Sorry. I ended up assigning the parameters to local variables which caused the sp to execute in 2 seconds. I don't quite understand the logic behind this solution. When should this be done? I read that the execution plan gets screwed up but even flushing the cache would not solve the problem.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-16 : 14:34:35
I found that interesting:
http://omnibuzz-sql.blogspot.com/2006/11/parameter-sniffing-stored-procedures.html

Webfred

Planning replaces chance by mistake
Go to Top of Page
   

- Advertisement -