In our software, we tend to reuse fairly complex SQL statements which
are generated at runtime. The SQL statements are executed by COM+
components.
In an effort to improve performance, we want to create a cache of
previously run statements whose values in a where clause may differ.
To do this, we were going to use parameters to the command object and
use the "Prepared" property assigned to TRUE.
What this allows us to do is basically store the cached Command objects
that have pre-parsed the SQL statements and simply replaces the values
of the where clause.
Right now, for some statements, it can take up to 10 seconds just to
perform the parsing whereas it only takes 1 second to actually execute
the statement (this was done through tests in SQL Query Analyzer where
the first execution of a statement took 11 seconds and the second
execution took 1 second).
My questions are:
1: Has anyone else done this and can they provide some sample code or a
URL link with examples of how to do this.
2: Will this even work to improve performance?
3: For string parameters, should the quotes be in the pre-compiled
command object or in the parameters to the command object?
Thanks for any help.
Pete Davis