select pg_class.relname,pg_locks.* from pg_class,pg_locks where pg_class.relfilenode=pg_locks.relation;
select * from pg_locks;
select * from pg_locks where granted = 'f' //the query that is waiting
select * from pg_locks where transactionid = 'xx' // queries running in a transaction
select * from pg_stat_activity
##References http://rhaas.blogspot.in/2011/01/locking-in-postgresql.html
http://fishbowl.pastiche.org/2004/02/26/finding_open_locks_on_postgresql/
http://www.postgresql.org/docs/current/static/explicit-locking.html
http://stackoverflow.com/questions/1153364/postgresql-exclusive-lock-stops-application