Tuesday, March 27, 2012

Cursor out of time

Hi,

First of all sorry about poor english.
I have the next problem:
I have a store procedure which declares a cursor which is a select from some tables. Im surprised because the sp takes over 10 seconds on working and if i execute the select of the cursor as separate ways, it takes no more one second. Ive changed the select with another easier select and it works 0 seconds, so it seems that the problem is in the select, but only if i use a cursor to save the regs, why????

Thanks a lot.Use the "show execution plan" option to see how the server is executing the three queries. Check to see what it different between them. My guess is that there is something causing the optimizer to make a radically different choice for one or more of the queries, and that is what is making them take longer.

-PatP|||Just don't use cursors. :) What are you trying to do with the cursor?|||Thank you for answer.
I think that I meant wrong.
If I execute the select in the cursor it takes me over ten seconds but if I copy the select and paste in the query analyzer, it takes me 0 seconds. Besides this, if i change the select by other easier one, the cursor takes 0 seconds. I know the first select could be wrong but it works 0 seconds in the analyzer!!!! and inside the cursor there is not any operations.

Thanks a lot...

No comments:

Post a Comment