Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

after tuning my Stored procedure is taking more time

$
0
0

Hi,

I have a stored proc which is taking some 40 secs to give the result set. I wanted to tune the SP. So i included the actual execution plan to see if any indexes are missing. We have used few temp tables in our logic to populate the data.All the missing indexes shown by the execution plan has been created now. Even non-clustered indexes has been created for the temp tables inside our logic.

This improved the performance a little. the was taking 30 secs. Then this mystery happened. I saw in the execution plan that the optimizer is still scanning the temp tables in most cases. So i just commented the CREATE INDEX part of logic and ran the SP to get the execution plan to see where it is seeking and where it is scanning. SP took more than 40 secs this time.

After i cant able to do anything, i thought to uncomment the commented lines in the logic, so that the query will run in <30 secs as before.

To my shock, the same query is taking more than 40 secs now. I cant understand, because i didnt change any logic.

Can anyone please provide me any link to learn in depth about the query optimizer, how it works?how the execution plan is generated?What are the factors query optimizer look after for generating a query plan?

Thanks in advance


Viewing all articles
Browse latest Browse all 15889

Trending Articles