Thread: patch: add get/setPrepareThreshold to PGStatement, PGConnection, datasources
patch: add get/setPrepareThreshold to PGStatement, PGConnection, datasources
From
Oliver Jowett
Date:
This patch adds setPrepareThreshold() and getPrepareThreshold() to PGStatement, PGConnection, and the myriad Datasource implementations. It also supports setting the threshold via a connection URL (this needs testing). The prepare threshold controls automatic use of server-side prepared statements without the need for a postgresql-specific interface (at least if you do it via reflection at the datasource level, or via a URL parameter). A threshold is stored at each level of the datasource/connection/statement hierarchy; the threshold on datasources and connections controls the initial threshold of connections and statements (respectively) created from them. If the prepare threshold of a Statement is 0 (the default) then server-side prepared statements are not used (equivalent to the current default). If the prepare threshold of a Statement is some value N > 0, server-side prepare will be used for that statement on its Nth reuse, assuming the query is suitable for server-side preparation. This means if N = 1, server-side prepare is always used (equivalent to PGStatement.setUseServerPrepare(true) in the current code). The threshold only really makes sense for PreparedStatements and CallableStatements as plain Statements can't actually be "reused" -- each query is independent. Currently, though, no distinction is made i.e. with a threshold of 1 everything does PREPARE/EXECUTE including queries via the plain Statement methods. -O