Closed SantoshMathew closed 6 years ago
We are using postgres' Zenpack in production and our locks data is showing much bigger than it is in reality.
This works with simple EQUI joins as well i.e. without using the INNER join syntax.
So, the query can be simplified to :
SELECT d.datname, l.mode, l.granted FROM pg_database AS d JOIN pg_locks AS l ON l.database = d.oid WHERE NOT d.datistemplate AND d.datallowconn;
The query is using a LEFT join which is a LEFT outer join really, so it returns databases which don't have a lock with the mode and granted column as null.
Changed the LEFT join to INNER join to fix the problem