My applications runs queries against a sql server database.
In many cases I can see the benefit of an execution plan: for example I click for the first time on a button to
SELECT * from Tasks
WHERE IdUser = 24 AND
DATE < '12/12/2010' and DATE > '01/01/2010'
it takes 15 seconds the first time, 8 seconds the following times.
EDIT: I USE PARAMETRIZED QUERIES.
So I have a 7 seconds improvement the second time.
Now as I run the application again (so I do a new database connection) the first time it will take 15 seconds, the second time 7...
How is it possible to tell SQL Server to store the execution plans, at least to remember them for same days? Or however how can I get benefit of already calculated execution plans? If different users run the same query is it a way to tell sql server to be smart enough to use the same execution plan, even if in that case probably the IdUser will be different.
In software I have some parameters, so may be the next execution of the query will have different MinDate and MaxDate, but will this affect the query plan?