Prepared by TADOQuery

The TADOQuery component has a “prepared” property, the manual says that when TRUE is set, ADO “prepares” the command, what does this mean?

Here is a guide explanation:

Set Prepared before calling the Execute method to indicate whether ADO is preparing the command. If Done is set to True and the component command is connected to the data warehouse, ADO prepares the command before executing it. If Done is set to False, ADO does not prepare the command.

Does it inject parameters into SQL text?

+4
source share
2 answers

Here's more detailed documentation from the Delphi 2007 help file:

Use the Finish property so that the provider saves the prepared (or compiled) version of the request specified in the CommandText property before the first execution of the Command object. This may slow down the execution of the first command, but as soon as the provider compiles the command, the supplier will use the compiled version of the command for any subsequent executions, which will increase performance.

If the property is False, the provider will execute the Command object directly without creating a compiled version.

If the provider does not support team preparation, it may return an error if this property is set to True. If the provider does not return an error, it simply ignores the command preparation request and sets the Prepared property to False.

This basically means that the SQL statement has been compiled (pre-parsed, marked, and parsed). When a query is used more than once, this compiled version can be used every time, simply substituting the parameter values, not recompiling all the instructions and do other work.

+5
source

Tt to reduce parsing and compile overhead associated with repeatedly executing an SQL statement that is executed many times.
An application can execute a parameterized statement several times, providing another parameter set at each execution, instead of restoring an instruction whenever the set of parameters is different.
Fulfillment of prepared statements

+2
source

Source: https://habr.com/ru/post/1469220/


All Articles