You are viewing an older version of this section. View current production version.
Prepared Statements
MemSQL version 6.7 and later supports prepared statements; however, server-side prepared statements are not supported when using Audit Logging. If Audit Logging is enabled, attempting to run server-side prepared statements will return the error Feature 'Audit logging with binary protocol' is not supported by MemSQL.
If you are using an older version of MemSQL, or using MemSQL with Audit Logging enabled, server-side prepared statements are not supported. Instead, many client drivers support a configuration option to allow client-side prepared statements. This configuration option may also be referred to as client-side prepared statement emulation or parameter interpolation. You can 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, set
useServerPrepStmts=false
, which is the default configuration https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html. - In MariaDB Connector/J, set
useServerPrepStmts=false
https://mariadb.com/kb/en/about-mariadb-connector-j/. - In ODBC, set
no_ssps=1
https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html. - In the Go MySQL driver, set
interpolateParams=true
https://github.com/go-sql-driver/mysql#interpolateparams. - In PHP PDO, set
PDO::ATTR_EMULATE_PREPARES=TRUE
https://www.php.net/manual/en/pdo.setattribute.php.
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.