-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDBC driver support for parallel queries? #1246
Comments
@torrejonv , are you sure you use select + executeQuery? Could you collect trace logs (see |
Hi, Trace logs do not provide a lot (notice it is a prepared statement, so the query is not appearing): Jul 11, 2018 4:44:19 PM org.postgresql.core.v3.QueryExecutorImpl processResults For a reproducible test case - I'll come back to you with a test script. |
I'm looking for
As far as I understand the log is missing "execute/bind" FE messages. Could you cite them as well? |
Is this not it? FINEST: simple execute, handler=org.postgresql.jdbc.PgConnection$TransactionCommandHandler@30e8e487, maxRows=0, fetchSize=0, flags=22 |
Of course it is not. Like this one:
However, that execute message was for a |
This is probably more like it, after disabling the preparedThreshold. Jul 11, 2018 5:05:36 PM org.postgresql.core.v3.QueryExecutorImpl sendParse Jul 11, 2018 5:05:38 PM org.postgresql.core.v3.QueryExecutorImpl processResults |
That is you are using limit=20. It can come from: Could you please double-check |
OK, this is definitely a pointer for us. For what I can see, pstmt.getFetchSize() is indeed 20. Nothing is modifying the pstmt (it's just created "as conn.prepareStatement(sql)"), so this seems to be a limit in the connection itself. ((PgConnection) JdbcTools.unwrappedConnection(conn)).getDefaultFetchSize() == 0 though. We will investigate it on this end, now that we have a pointer. |
Could you add a breakpoint into |
OK problem solved! We had a connection wrapper modifying the fetch size - that affected all prepared statements by default. Thank you for the help troubleshooting this, Vladimir. WE are now seeing parallel queries. |
Hello,
JDBC Driver 42.2.2.
Java 10.0.1
Postgresql 10.4
During tests, we have noticed we cannot trigger parallel queries when using the JDBC. Query being executed via PSQL shows parallel query execution planned and performed (for example: "Workers Planned: 2, Workers Launched: 2".
However, running the same query via JDBC shows that the query was planned in parallel, but not executed in parallel. Typical output is: "Workers Planned: 2, Workers Launched: 0". The query is planned for parallel execution, but it is then performed in a single thread. We only see this behaviour when going via the JDBC.
The documentation comes with some notes indicating cases where parallel queries are not applicable, however we cannot see why any would apply:
"https://www.postgresql.org/docs/current/static/when-can-parallel-query-be-used.html:
"Even when parallel query plan is generated for a particular query, there are several circumstances under which it will be impossible to execute that plan in parallel at execution time. If this occurs, the leader will execute the portion of the plan below the Gather node entirely by itself, almost as if the Gather node were not present. This will happen if any of the following conditions are met:
...
...
"
We do not modify the default isolation level, and are not using fetch size for these particular queries.
Example code (modified some bits for confidentiality), no fetch size enforced:
PreparedStatement ps = null;
ResultSet rs = null;
....
So, we are out of ideas by now. Is the JDBC meant to be compatible with PG 10 parallel queries? If it is, is there any reason why we would experience the described behaviour?
The text was updated successfully, but these errors were encountered: