Interview Q&A · questions with model answers
Databases & Transactions Interview Questions
Part of the study plan for: Backend Engineer · Full Stack Engineer · Data Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Compare optimistic and pessimistic locking.
Pessimistic locking acquires a lock when reading (SELECT ... FOR UPDATE) so others wait; optimistic locking lets everyone read and checks a version column at update time (WHERE id = ? AND version =…
-
Should primary keys be auto-increment integers or UUIDs?
Integers are compact and index-friendly but reveal counts and are hard to generate across systems; random UUIDv4 avoids enumeration and allows client generation but fragments B-tree indexes;…
-
When do you need a dedicated search engine instead of SQL LIKE queries?
When you need relevance ranking, typo tolerance, stemming, facets, fuzzy matching or fast search over large text, use Postgres full-text search for moderate needs or a search engine…
-
When is storing JSON in a relational database appropriate?
JSON/JSONB columns suit semi-structured or sparse attributes, external payloads, and evolving metadata. Keep frequently queried and constrained fields as real columns, index JSON paths you filter on…
-
How do you perform large data updates or backfills safely?
Process in small batches by primary key ranges, commit per batch, throttle to protect production load, make the job idempotent and resumable, monitor replication lag, and run during low traffic.