Use statement caching

2023-07-26 09:37:05  Updated

OceanBase Connector/J calls API operations to enable or disable statement caching and set the number of callable statements and the maximum number of SQL statements that can be cached.

The following table describes the parameters.

Parameter Description
useServerPrepStmts Specifies whether to execute PrepareStatement on the server before execution. Generally, a direct command (text protocol) is used to activate this option. This parameter is correlated with the rewriteBatchedStatements parameter. If rewriteBatchedStatements is true, this parameter is set to false. Default value: false.
cachePrepStmts Specifies whether to cache the prepared statements. If useServerPrepStmts = true, commands that are composed of the prepared statements are cached in the LRU cache to avoid re-preparing the commands. The next time you execute a prepared statement that is cached in the LRU cache, the prepared identifiers and parameters, if any, will be sent to the server. With this option, the server does not need to re-parse the statement. Default value: true.
prepStmtCacheSize The size of the Prepared Statement cache for cachePrepStmts when useServerPrepStmts = true. Default value: 250.
prepStmtCacheSqlLimit The maximum number of prepared statements that can be cached. If useServerPrepStmts = true, prepared statements beyond this threshold will not be cached. Default value: 2048.
cacheCallableStmts Specifies whether to enable caching Callable Statements. Default value: true.
callableStmtCacheSize The maximum number of callable statements that OceanBase Connector/J can cache for each virtual machine (VM) if cacheCallableStmts is set to true. Default value: 150.

Contact Us