Board index » delphi » Should I be "Prepared"?

Should I be "Prepared"?

To Prepare or not Prepare, that is the question.

If you are calling a Stored Procedure repeatedly in succession that exists
in a compiled state on the server, do you need to first call the prepare
method? Or is it already in a prepared state?

I am under the impression that only when you are dynamically composing SQL
do you need to call the prepare method, otherwise if all that is changing
are the stored procedure's parameter values, then calling the prepare method
is not necessary and an overkill.

Is this last assumption correct?

Thanks,

--
Reid Roman
Future Generation Software
http://www.fgsoft.com
re...@fgsoft.com

 

Re:Should I be "Prepared"?


Currently, MSSQL 2000.

Thanks,

--
Reid Roman
Future Generation Software
http://www.fgsoft.com
re...@fgsoft.com

Re:Should I be "Prepared"?


From my experience, no.  Your mileage may vary.

Your best way to find out is to test it, see what happens.

Good luck,
krf

Quote
"Reid Roman" <re...@fgsoft.com> wrote in message

news:3e494894@newsgroups.borland.com...
Quote
> Currently, MSSQL 2000.

> Thanks,

> --
> Reid Roman
> Future Generation Software
> http://www.fgsoft.com
> re...@fgsoft.com

Re:Should I be "Prepared"?


There are 2 prepares that should be considered using a sp.

1st
a sp is stored in a compiled way in the database,
so the database do not need to optimize the sp each time it is executed.

2nd
While executing a sp the database has to check if the user has the rights to
execute the sp, has to check to parameter list and so on.
This is done each time you execute the sp.
If you prepare the sp, this is only done the first time.

Heiko

ps: this is true for interbase, firebird, but should be also true for mssql

Other Threads