Skip to main content
InterviewHubPRO
Section Overview
Q27

Question 27 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

54%
PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

How does PostgreSQL handle Lock Modes and Lock Contention?

senior LevelDatabases & SQLPostgreSQL

In Simple Words: PostgreSQL features 8 table-level lock modes and multiple row-level lock modes:

  • ACCESS EXCLUSIVE: Most restrictive. Acquired by DROP TABLE, ALTER TABLE, and VACUUM FULL. Blocks all reads and writes!
  • SHARE UPDATE EXCLUSIVE: Acquired by VACUUM (non-full), ANALYZE, and CREATE INDEX CONCURRENTLY. Allows concurrent reads and writes (SELECT, INSERT, UPDATE).
  • Rule: Always create indexes in production using: CREATE INDEX CONCURRENTLY idx_name ON table(col); (takes longer to build, but never acquires exclusive locks!).