I am using the latest version of java client 2.2.2 but it looks like it is not possible to do prepared statement with it. As Couchbase Server 4.1 GA is out and officially support prepared statement, any idea or time frame to an update to the SDK to support it?
@lbertrand it is! on the query params, set adhoc(false) and you’re good to go. It will automatically use prepared statements in the background. If you have changing parameters, I recommend using parameterized queries and setting adhoc(false)
@daschl I’m completely new to Couchbase and I’m very curious about how this works under the hood (both server and the Java sdk). I have the following questions:
Suppose I have multiple front-end servers that use the same prepared statement via this adhoc(false), will the Couchbase server create duplicated prepared statements that are essentially the same? Can it happen that over time, there are too many prepared statements stored in the server?
Is there anyway to give a name to the prepared statement so that all front-end servers will use the same prepared statement? And if yes, is there a way to delete a prepared statement using its name? Couchbase server also creates random names for the prepared statements. How are these handled at the sdk level?
There’s a mention of caching of query plan of the sdk in the doc. So when a statement with adhoc(false) is created, the sdk would search in cache using the statement for a cached query plan and execute it if possible. Otherwise, it will tell the server to execute the plan saved in the server?