You are viewing an older version of this section. View current production version.
Prepared Statements
MemSQL does not support server-side prepared statements. However, many client drivers support client-side prepared statements which work with MemSQL.
There are two related but different concepts of prepared statements: the prepared statements API exposed by the client driver (client-side prepared statements), and the prepared statements client-server protocol (server-side prepared statements). In general, it is possible to use both, or to use client-side prepared statements without server-side prepared statements. In MemSQL, only the latter is supported.
In many other databases, server-side prepared statements provide performance advantages, but MemSQL already compiles and caches query plans internally, so MemSQL does not need server-side prepared statements to get most of those performance advantages.
Many drivers support client-side prepared statements without server-side prepared statements, i.e. using the prepared statements API in your application while sending non-prepared statements to the server. This may also be referred to as client-side prepared statement emulation or parameter interpolation. This allows you to use the same code in your application, but just change a flag in the client driver configuration. For example:
- in the MySQL Connector/J (JDBC) driver, configuring
useServerPrepStmts=false
, which is the default configuration (http://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html). - in MariaDB Connector/J, configuring
useServerPrepStmts=false
(https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/) - in ODBC, configuring
no_ssps=1
(https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html) - in the Go MySQL driver, configuring
interpolateParams=true
(https://github.com/go-sql-driver/mysql#interpolateparams) - in PHP PDO, configuring
PDO::ATTR_EMULATE_PREPARES=TRUE
(http://php.net/manual/en/pdo.setattribute.php)
MemSQL has an experimental, prototype implementation of server-side prepared statements, which is not supported in production. It is disabled by default, and may be enabled by setting enable_binary_protocol=true
.