0

I want to execute multiple select statements in the same JDBC query, in order to amortize network latency over a number of related queries, as described in this question:

Multiple queries executed in java in single statement

The accepted answer is to use allowMultiQueries=true. Unfortunately, this is a feature specific to the MySQL JDBC driver.

What is the equivalent in PostgreSQL JDBC?

Alex R
  • 11,364
  • 15
  • 100
  • 180
  • 1
    The example in the linked question could be done in a single query in Postgres. If you have non-trivial statements, I doubt that sending all of them in one go makes a measurable difference to be honest. Make sure you are using a connection pool in your application to avoid opening a new physical connection for each query. –  Apr 20 '22 at 05:30
  • 3
    Additionally: you don't need such a parameter in Postgres. You can just run `"select a,b,c from one_table; select x,y from other_table;"` using `Statement.execute()`. Then you can use `Statement.getMoreResults()` and `Statement.getResultSet()` to iterate over all ResultSets –  Apr 20 '22 at 05:46

0 Answers0