Если кому интересно: есть еще функция pg_stat_get_activity, которая
Returns a record of information about the backend with the specified PID, or one record for each active backend in the system if NULL is specified. The fields returned are a subset of those in the pg_stat_activity view