Proc times out in app not in ssms

  • I have a proc that times out (31 seconds with 30 second limit) when run from the application (proc alone on the page). But when ti is run in ssms it runs in 2 seconds. There is no network issues at all as this is a test environement.

     

    I created a covering index and it flys now.

     

    But why does it run fine without the index in ssms and not in the app?

  • Have you taken a look to the execution plan for each case?

    It should differ ...

    It seems that you have an index seek (fast query) and an index scan (slow query).

    You have no garantee that the query optimizer uses a "real" optimized execution plan. Even if you have a query with a WHERE on exact one field and this field is indexed.

    In this case you have to use plan hints to optimize the optimizer. 😉

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply