postgresql commit 13d00729d422c84b1764c24251abcc785ea4adb1 renamed blk_read_time/blk_write_time columns. That's why the symlink didn't work with the new version.
While here, slightly change IO timing calculations: now it includes in addition to shared_blk_read_time also local_blk_read_time and temp_blk_read_time. These are also IO timings, so it will be more correct this way. Similarly with write timings.
It might desirable to see which object we're waiting on.
To do so join to the pairs by both, locker and waiter, otherwise
duplicates are prodcued.
To do so add `dad` column to the `tree` subquery.
It was tempting to also change database and relation (wherever possible)
oids into names, but I choose not to do so.
It turns out that quite frequently single session will block others on
different objects, especially if it is idle in transaction. Therefore
get rid of the `mode` column in `leads` and `tree` subqueries and group
leads only by locker.
This lead to the change for the non-cyclic sessions. As `mode` is gone,
lockers are filtered by highest level instead.
Last change was to get rid of early cycle checks in the `leads` subquery,
as it is causing wrong results when tree is formed.
It might happen that all lockers are also waiting on some other resources,
which leads to empty output.
Properly detect locking leads via another recursive check on lockers only.
In cases where locker is holding several locks on the same entry,
make sure to use only the highest lock to avoid duplicates.
Lock mode is transfered into numeric form via array. It is possible
to convert it back, but as mode is not shown in the final output
I choose not bother.
1) display warnings when DB is close to xidWrapLimit by 200M transactions
2) remove '\r' symbol from queries for better display at email clients
fix incorrect numbering of queries when there is no 'other' query, fix IO percentage at total time when there is very little / no activity on database since last pg_stat_statements reset.