The locks a query holds
A SELECT takes AccessShareLock on the table. Locks last until the statement or transaction ends, so read pg_locks inside the same statement.
task
In one statement, count lab.t and list the modes of pg_locks rows of this backend on lab.t.