Hello, This is available in https://github.com/legrandlegrand/pg_stat_sql_plans extension with a specific function pgssp_backend_queryid(pid) that permits to join pg_stat_activity with pg_stat_sql_plans (that is similar to pg_stat_statements) and also permits to collect samples of wait events per query id.
This extension computes its own queryid based on a normalized query text (that doesn't change after table drop/create). Maybe that queryid calculation should stay in a dedicated extension, permiting to users to choose their queryid definition. Regards PAscal -- Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html