I presume the difference between you running your queries via
psql vs. from a Java program is that you use prepared statements in Java. Processing "simple statements" and prepared statements take different code paths in the Postgres backend (postgres.c).
"query-start" probe is only called when a simple statement is executed (
exec_simple_query), while a prepared statement processing has two separate distinct stages: parse (
exec_parse_message) and execute (
Both code paths converge when they call
PortalRun in pquery.c, where the "query-execute" probe is called.
In other words, the two code paths look like this (omitting the "done" probes):
psql -> simple statement
JDBC -> prepared statement
If you're not particularly concerned about the query parsing and planning latency, you need to capture the "query-execute-*" probes. If you need the query text, capture also "query-parse-start".