Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Going parameterized causes problem
Message
 
 
À
30/09/2008 15:48:41
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01351844
Message ID:
01351929
Vues:
26
>>Try to add
>>
>>OPTION (RECOMPILE)
>>
>
>I have found that if I remove the TOP 100 clause that this helps. Basically, I get results within a second or up to three seconds. When I have this clause, it can take between 20 and 100 seconds. So, basically, I have removed it from the six locations where it was before in the code.
>
>However, with OPTION (RECOMPILE), the result was instant. I also tried with other searches and it is always as VFP was doing it.
>
>I also found that with OPTION (RECOMPILE), queries that were running before without the TOP 100 clause, which were running ok, are also faster.
>
>What does it do exactly? Should I include that in all my SQL exec command?

The OPTION (RECOMPILE) tells the SQL Server Query Processor to not cache the query plan. As result every new parametrized query gets new execution plan instead of reusing a previous one that may not be optimized for the current parameters values.
For a simple query producing new execution plan should be cheap compare to the performance lost. It could be not the case for a complex one.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform