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:

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.

Was this article useful?