I'm writing a client side tool that is querying a Postgres DB using PreparedStatements. I'm running into some issues. This tool has to support a wide variety of Postgres setups. Some of these setups use pgBouncer in transaction pooling mode, which doesn't support prepared statements. It's not easy to determine this before the fact, so a workaround here is to retry with the prepareThreshold=0 jdbc param set.
I'm trying to figure out what the effects of setting the jdbc param prepareThreshold=0 by default would be.
As I understand the effects of setting this parameter are:
Client side benefits of prepared statements (allocating fewer Java objects, preventing SQL injection) will not be affected.
PreparedStatements are no longer cached. Are only beneficial server side if you are making the same queries over and over again. I believe the default value is 5 (that is one sees performance gains only after 5 repeated queries)
The tool I'm working only issues a couple of queries, so I'm trying to understand whether it's safe for me to add this JDBC param or not, and what the effects of this could be.