Re: Time out
- From: "Alberto Poblacion" <earthling-quitaestoparacontestar@xxxxxxxxxxxxx>
- Date: Tue, 15 Jul 2008 20:18:29 +0200
"Le Hung" <Le Hung@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:144D22B4-924F-4D0F-AF2F-48243BFB7A10@xxxxxxxxxxxxxxxx
[...]
The above procedure will return a data set in one second.
I can not see the different between 2 procedures any one run into the same
problem before please help.
The only difference that I see between both querys is that the "slow" one is parameterized while the second one is not. The difference in speed could be in Sql Server: The parameterized query is optimized once and then stored in the procedure cache, so that every time you send the same query, even though the values of the parameters are different, it follows the same strategy. On the other hand, the non-parameterized version is optimized every time, which will be a little less efficient, but will always choose the best index according to the current index statistics.
If your database statistics are not up-to-date, or you first executed the parameterized query with a set of parameters that happened to provide optimal performance with a full scan (according to the existing statistics at that time), the parameterized query might have been optimized for a full clustered index scan.
I recommend that you UPDATE STATISTICS and then clear the procedure cache (DBCC FREEPROCCACHE) so that your query will be recompiled.
By the way, your indexing strategy is probably suboptimal, at least for this query: You have a very wide clustered index, which needs to be appended to every other index, making those querys slower. You would probably benefit from changing the primary key to non-clustered.
.
- References:
- Time out
- From: Le Hung
- Time out
- Prev by Date: Reading an opened file in C#
- Next by Date: How do I add a treenode with a key?
- Previous by thread: Time out
- Next by thread: Re: Time out
- Index(es):
Relevant Pages
|