Postgresql – Disable nestloops into the Postgresql JDBC connection

jdbcpostgresql

I'd like to disable nested loops for a specific JDBC connection string (batch java application), using the PostgreSQL community driver

Is it possible to do so?

I tried this way, in vain:

jdbc:postgresql://xxx.yyy.zzz:5432/mydb?options=enable_nestloop=off

Best Answer

You can use the options connection parameter, as explained here:

  • options = String

Specify 'options' connection initialization parameter.

The value of this property may contain spaces or other special characters, and it should be properly encoded if provided in the connection URL. Spaces are considered to separate command-line arguments, unless escaped with a backslash (\); \\ represents a literal backslash.

So that should look like

options=-c%20enable_nestloop%3Doff

But I share the horse's concern that this may be a bad idea, and you should rather tune your queries.