I have noticed, if query comes from PostgreSQL JDBC Driver, then query_id is not present in pg_stat_activity. Erik Wienhold figured out that reason can be in extended query protocol (https://www.postgresql.org/message-id/1391613709.939460.1684777418070@office.mailbox.org) My question is, is it expected or is it a bug: if extended query protocol then no query_id in pg_stat_activity for running query.