Why does a count obtain an ExclusiveLock in Postgresql?
Every transaction is born owning an ExclusiveLock on itself.

For a read-only transaction, this will only block things like CREATE INDEX CONCURRENTLY.  For DML transactions, this lock will be used to block other transactions trying to update or delete the same row, or insert conflicting rows.