Interview Q&A / PostgreSQL
PostgreSQL interview questions
Indexes, EXPLAIN, transactions and isolation, JSONB and the Postgres specifics backend interviews probe.
Prefer rapid revision? Practise PostgreSQL short interview answers →
- How do you add a foreign key or CHECK constraint to a huge table without a long lock?
Add it as NOT VALID, which skips the check of existing rows and only needs a brief lock, then run VALIDATE CONSTRAINT separately. Validation scans the table but only takes a weaker lock, so writes continue.
AdvancedQuick answer1 min read