6.8 Using the Connector/Net with Prepared Statements

6.8.1 Preparing Statements in Connector/Net

Use of prepared statements can provide significant performance improvements on queries that are executed more than once.

Note

Prepared statement support is available with MySQL 4.1 and above.

Prepared execution is faster than direct execution for statements executed more than once, primarily because the query is parsed only once. In the case of direct execution, the query is parsed every time it is executed. Prepared execution also can provide a reduction of network traffic because for each execution of the prepared statement, it is necessary only to send the data for the parameters.

Another advantage of prepared statements is that, with server-side prepared statements enabled, it uses a binary protocol that makes data transfer between client and server more efficient.

Note

Enable server-side prepapared statements (they are disabled by default) by passing in "IgnorePrepare=false" to your connection string.