Databases Reference
In-Depth Information
The SQLExecDirect function is optimized for a SQL statement that is only
executed once. In contrast, the SQLPrepare / SQLExecute functions are optimized
for SQL statements that use parameter markers and are executed multiple times.
Although the overhead for the initial execution of a prepared statement is high,
the advantage is realized with subsequent executions of the SQL statement.
Using the SQLPrepare / SQLExecute functions typically results in at least two
network round trips to the database server:
One network round trip to parse and optimize the statement
One or more network round trips to execute the statement and retrieve
results
Performance Tip
If your application makes a request only once during its life span, using
the SQLExecDirect function is a better choice than using the
SQLPrepare/SQLExecute function because SQLExecDirect results in only
a single network round trip. Remember, reducing network communica-
tion typically provides the most performance gain. For example, if you
have an application that runs an end-of-day sales report, send the query
that generates the data for that report to the database using the
SQLExecDirect function, not the SQLPrepare / SQLExecute function.
See “SQL Statements,” page 27, for more information about statements ver-
sus prepared statements.
Using Arrays of Parameters
Updating large amounts of data typically is done by preparing an Insert state-
ment and executing that statement multiple times, resulting in many network
round trips.
 
Search WWH ::




Custom Search