Database Administrator question bank
515 questions. Filter by level and skill, track what you've solved, and see how many people get each one right.
- Purpose of a primary key
- Third normal form
- When a B-tree index helps
- Durability in ACID
- INNER JOIN vs LEFT JOIN
- Full vs incremental backup
- Least privilege for an app user
- DELETE vs TRUNCATE
- Filtering rows where a value is NULL
- COUNT(*) vs COUNT(column)
- What a foreign key enforces
- WHERE vs HAVING
- Data type for money
- Stopping SQL injection
- Logical vs physical backup
- Proving backups work
- RPO and RTO
- Why a write-ahead log exists
- Read-only access for analysts
- What pg_hba.conf controls
- View vs materialized view
- What ROLLBACK undoes
- UNION vs UNION ALL
- Row order without ORDER BY
- Why add a read replica
- Seeing what is running now
- Cancel or terminate a session
- Why InnoDB over MyISAM
- Gaps in auto-increment IDs
- Storing event times
- Rejecting bad values
- FATAL: too many clients
- Finding slow MySQL queries
- Encrypting client connections
- Downtime allowed by 99.9%
- Error budget for a 30-day month
- Replicas after a bad DROP TABLE
- The 3-2-1 backup rule
- Spotting a single point of failure
- Active-passive vs active-active
- Making a PostgreSQL server a standby
- Copying data for a new replica
- Failures a 3-node quorum survives
- Why keep a delayed replica
- Turning a standby into the primary
- RDS backup retention limit
- Where an RDS point-in-time restore goes
- What a pilot light setup keeps running
- Planning the way back
- Planned switchover vs failover
- Worst-case data loss from backups
- What an RPO of zero requires
- Adding replicas to fix slow writes
- Partitioning vs sharding
- Why run DR game days
- Eleven nines of durability
- Removing a server without dropping users
- Keeping a shop usable during DB failover
- Rebuilding the stack in a new region
- Restoring one dropped table
- Kafka topic replication for HA
- Stopping calls to a failing dependency
- Standby fell too far behind
- Servers flapping in and out of a pool
- What hot standby means
- Seeing connected standbys
- Grandfather-father-son retention
- Index on a yes/no column
- How InnoDB stores table rows
- What an InnoDB secondary index points to
- LIKE with a leading %
- What a hash index supports
- Cost of extra indexes on inserts
- EXPLAIN versus EXPLAIN ANALYZE
- type = ALL in MySQL EXPLAIN
- Index for a date range
- Indexes created automatically
- Index not used on a tiny table
- Duplicate-looking indexes
- Index Cond versus Filter
- What ANALYZE does
- COLLSCAN in a MongoDB plan
- One composite or two single indexes
- What Seq Scan means
- Fast MAX on an indexed column
- Writes for one insert
- Indexing the join column
- ORDER BY random()
- Order of fields in a MongoDB index
- A unique index used for search
- What UPDATE does under MVCC
- Applying a minor PostgreSQL release
- Which part is the major version
- Applying a pg_hba.conf change
- CREATE USER vs CREATE ROLE
- Where roles live
- Where is the MySQL query cache
- Emoji fail to save in MySQL
- Sizing the InnoDB buffer pool
- Data type for rupee amounts
- Loading 5 crore rows quickly
- Emptying a staging table
- Real size of a table
- Spotting indexes no one uses
- Remote clients cannot connect
- VACUUM vs ANALYZE
- Capping query time for one role
- Role for a monitoring agent
- Same MySQL user, different host
- Where to move from MySQL 8.0
- Old client fails to log in to MySQL 8.4
- Extension missing in another database
- Where new databases come from
- Password file ignored by psql
- Client TLS mode that stops spoofing
- NOT IN returns no rows
- Counting rows with NULL phones
- Where big text values go
- Getting disk back from a MySQL table
- Binary logs filling the disk
- Granting one set of rights to many MySQL users
- Recording who logged in
- Big table read by full scans
- Which postgresql.conf is in use
- Checking if the server accepts connections
- Consistent mysqldump without locks
- What C in ACID means
- What I in ACID means
- Statements without BEGIN
- What a phantom read is
- PostgreSQL default isolation
- Undoing part of a transaction
- Locking a row you will change
- Not waiting for a locked row
- Rolling back a CREATE TABLE
- DDL in a MySQL transaction
- Lock taken by a plain SELECT
- Does VACUUM block the app
- ACID vs eventual consistency
- Stopping negative wallet balances
- When others see your changes
- Setting the level for one transaction
- BEGIN inside a transaction
- Guarding a reporting transaction
- Two uncommitted writes to one row
- Undoing a TRUNCATE
- Trigger failure and the main write
- Why long transactions hurt
- Deleting 5 crore old rows
- Insert or update in one statement
- now() inside a long transaction
- Client retries a payment request
- What a saga does on failure
- When row locks are released
- Holding a lock while the user decides
- How committed work survives a crash
- Open transaction during a crash
- Lock wait vs deadlock
- What optimistic locking means
- Composite index column order
- Reading an EXPLAIN ANALYZE plan
- Non-repeatable read
- Why PostgreSQL needs VACUUM
- What PITR needs
- Risk of asynchronous replication
- Why use a connection pooler
- Covering index
- Slow deep pagination
- Which query to tune first
- NOT IN returns nothing
- UNIQUE column with NULLs
- Adding an index on a live table
- Sort Method: external merge
- Bad plan right after a bulk load
- Sizing shared_buffers
- Session state behind pgBouncer
- Workers fighting over jobs
- MySQL default isolation level
- Measuring replica lag
- Reports cancelled on the replica
- Is pg_dump consistent?
- Restoring a Percona XtraBackup
- Deleting a customer takes seconds
- Disk not freed after a big delete
- Bloat from an idle session
- A migration froze the whole app
- Indexing only pending rows
- Searching inside text
- Fast JSONB filters
- Row vs statement binlog format
- Multi-AZ vs read replica on RDS
- Terraform plan wants to replace the DB
- Counting a huge table quickly
- Availability of components in series
- Two redundant copies of a service
- Availability from MTBF and MTTR
- Four or five members for etcd
- Placing the tie-breaker
- What fencing protects against
- Sync replication that survives one replica loss
- Reading your own write on a replica
- Too many replicas on one primary
- Lossless semi-sync in MySQL
- Why GTIDs ease MySQL failover
- Stopping writes to a MySQL replica
- MySQL replica lags under heavy writes
- Replica lag spike after a batch job
- Users see old data after saving
- Connection string that finds the primary
- Routing to the Patroni leader
- How Aurora storage survives an AZ loss
- Lowest-effort cross-region DR for RDS
- Backups that ransomware cannot delete
- Restoring to just before a bad deploy
- New timeline after promotion
- Checking WAL archiving health
- InnoDB Cluster losing two of three
- Fast new MySQL replica
- MySQL point-in-time restore
- Kafka settings that do not lose acked writes
- Writes lost after Redis failover
- Choosing during a network partition
- Primary on the minority side of a partition
- Last-writer-wins drops a newer update
- Commit latency with a distant sync replica
- DR when data must stay in the UAE
- DR for Indian payment data
- Static stability during a zone failure
- Limiting the blast radius
- Database overwhelmed right after failover
- Sending reads to a lagging replica
- Unique IDs on many shards
- Moving one big tenant to its own shard
- Sync standby placed in the same zone
- Shorter app impact during RDS failover
- Which MySQL replica to promote
- Surprise bill from replica reads
- Equality and range in one index
- Reading loops in a plan
- shared hit versus read
- Why a Bitmap Heap Scan
- Feed page per user
- Gap in a composite index
- Phone number compared to a number
- LIKE prefix ignores the index
- Index for a huge append-only log
- "Using filesort" in MySQL EXPLAIN
- Finding indexes nobody uses
- OR across two columns
- ORDER BY with mixed directions
- random_page_cost on SSD
- Same query, different plans
- Checking if any row exists
- The N+1 query pattern
- Many rows removed by filter
- Testing an index drop safely
- ON CONFLICT needs a unique index
- Estimating rows for an equality filter
- Hash join with many batches
- Capturing plans of slow production queries
- Rows repeat across pages
- Stopping overlapping room bookings
- Hard-coding FORCE INDEX
- Spotting a missing index from stats
- MongoDB covered query
- Rebuilding a bloated index online
- Parallel workers in a plan
- When autovacuum starts on a table
- Vacuuming one hot table more often
- Shrinking a bloated table safely
- Autovacuum running though it is off
- Watching XID age per database
- Cost of 3,000 idle connections
- Server connections from PgBouncer
- Raising max_connections
- Where ALTER SYSTEM writes
- Password hashing method to use
- The pg_hba line that never applies
- Users cannot create tables in public
- Roles missing after a restore
- Making pg_restore use 8 cores
- Deleting a customer is slow
- I/O spikes at every checkpoint
- Index for a huge log table
- Modern auto-increment column
- Planner ignores a good index
- Computing the buffer cache hit ratio
- Major upgrade with minutes of downtime
- Testing pg_upgrade before the window
- Extensions after a major upgrade
- mysql_upgrade on MySQL 8.4
- Logging who read card data
- Seeing the plan of a slow query in prod
- pg_stat_statements view errors
- Checkpoints occurring too frequently
- What effective_cache_size does
- Planner prefers seq scans on NVMe
- Speeding up CREATE INDEX
- Member of a role but no access
- Jumping from MySQL 5.7 to 8.4
- Foreign keys and indexes in InnoDB
- UUID keys that index well
- Changing int to bigint
- Adding a foreign key to a big table
- Data silently cut in MySQL
- Reading type=ALL in MySQL EXPLAIN
- Deep pages load slowly
- Big aggregate uses one CPU
- CTE acts as an optimisation fence
- Stopping one query filling the disk
- Who is doing the I/O
- Avoiding double caching in MySQL
- What CLUSTER does
- Encrypting Aadhaar numbers in a column
- Bad estimates on a skewed column
- Which levels allow which anomaly
- Read Uncommitted in PostgreSQL
- Handling SQLSTATE 40001
- Two SELECTs, two answers
- When the Repeatable Read snapshot starts
- Could not serialize due to concurrent update
- UPDATE re-checks the WHERE clause
- FOR SHARE vs FOR UPDATE
- Flash sale stock without overselling
- Version check updates no rows
- Choosing optimistic or pessimistic locking
- Current transaction is aborted
- MySQL keeps going after an error
- Only one copy of a cron job
- App gets deadlock detected
- What deadlock_timeout controls
- MySQL lock wait timeout behaviour
- Finding who blocks a session
- Capping total transaction time
- Check-then-insert creates duplicates
- Preventing overlapping room bookings
- Swapping two unique positions
- Counting page views in MySQL
- Processing each message once
- Cache shows a rolled-back price
- Retry storms after deadlocks
- Retried transaction sends two emails
- BEGIN and UPDATE on different connections
- FOR UPDATE with GROUP BY fails
- Table lock from UPDATE
- Plain CREATE INDEX during traffic
- Reading pg_locks for waiters
- Logging long lock waits
- Several queries, one consistent picture
- Taking a MySQL snapshot at start
- LOCK TABLES in a transaction
- Saga orchestration vs choreography
- Why 2PC is avoided across services
- Does PostgreSQL escalate row locks
- Many commits, few disk flushes
- Timestamp used as a version check
- RETURNING gives no row on conflict
- Connections stuck idle in transaction
- More serialization errors on long transactions
- Fixing a recurring deadlock
- Transaction ID wraparound
- Partition pruning
- Choosing a shard key
- Index ignored because of a function
- InnoDB gap locks
- Avoiding split-brain
- Disk filling with WAL
- Two doctors go off call
- Commits hang with sync replication
- Prepared statement slows down later
- Estimates wrong for city and zip code
- Index-only scan still reads the table
- Logical replication stopped after a migration
- pg_upgrade --link and rollback
- pg_wal growing without limit
- Errant GTIDs block failover
- Online schema change tools for MySQL
- Unique email on a partitioned table
- Deleting old data every month
- Primary demoted when etcd is unreachable
- WAL volume spikes after checkpoints
- What encryption at rest protects
- Row-level security not applied
- Risky SECURITY DEFINER function
- Indexes bloat on a counter table
- Random UUID keys slow down inserts
- Rejoining the old primary
- OOM killer after raising work_mem
- Restore takes longer than the RTO
- Locks held by nobody
- Faster commits with a durability cost
- DR restore blocked by an encryption key
- A WAL archive with silent gaps
- Low traffic makes WAL archiving lag
- Files needed for a restore
- Native incremental backups in PostgreSQL 17
- Speeding up point-in-time recovery
- Snapshots of data and WAL volumes
- Keys moved when adding a shard
- All writes hit one shard
- How long Patroni waits before failover
- Replica skipped during failover
- CDC breaks after every failover
- Kubernetes keeps killing the database
- All replicas in one zone
- Capacity to survive losing a zone
- A transfer between two shards
- Joining a small table on every shard
- One celebrity account overloads a shard
- A DB blip removes every app server
- Running PostgreSQL on Kubernetes
- Why Patroni uses a watchdog
- Aurora Global Database in a regional outage
- Multi-AZ instance vs Multi-AZ cluster
- One replica always lags
- The drill took 3 hours, not 30 minutes
- Choosing logical or physical replication
- Routing users to the nearest healthy region
- How long a 3 TB restore takes
- Starting a chaos experiment safely
- Keeping WAL for replicas without slots
- Standby failures under ANY 2 of 4
- A base backup that will not start
- etcd split across two regions
- LIMIT 1 takes minutes
- Optional filters in one query
- Index on a frequently updated column
- Failed concurrent index build
- B-tree levels for 2 crore rows
- CTE stops using an index
- Index row size exceeds maximum
- Partitioned table with bad estimates
- NULLS LAST and the index
- IN list plus ORDER BY
- Join ignores the index
- Hot right edge of an index
- Physical order and index cost
- Estimates wrong for a skewed column
- Refreshing a dashboard view without blocking
- Fast DISTINCT on a low-cardinality column
- JIT makes a query slower
- Planning time with 5,000 partitions
- MySQL prefix index trade-off
- Choosing a clustered key
- Testing an index before building it
- High cache hit ratio, slow query
- Wrong results after an OS upgrade
- Checking an index for corruption
- When an int key runs out
- Adding NOT NULL to a big table
- ADD COLUMN that rewrote the table
- Inserts slow down with UUID keys
- InnoDB history list keeps growing
- Where old row versions are kept
- More autovacuum workers, no speed-up
- Out of shared memory with partitions
- Disk full with a large pg_wal
- Unlogged table empty after a crash
- UPDATE fails on a published table
- MySQL ignores an index on phone
- Online column add in MySQL 8
- Data checksums on new clusters
- A role that can run COPY FROM PROGRAM
- Measuring bloat exactly
- Query scans every partition
- Creating a partition takes ages
- Attaching a loaded partition quickly
- Slow query over postgres_fdw
- Reading EXPLAIN BUFFERS output
- Huge pages for a 64 GB buffer pool
- Linux OOM killer and PostgreSQL
- Write stalls from a small redo log
- Top queries without a slow log
- Finding queries that spill to disk
- Duplicate emails differing in case
- Any user can connect to any database
- Index-only scans slow on an insert-only table
- Duplicate key errors after cutover
- Standbys after pg_upgrade --link
- SELECT causes heavy writes
- Online ALTER fails at the end
- Old replication commands fail on 8.4
- Report total off by one transfer
- Foreign key checks and row locks
- Advisory locks behind PgBouncer
- SELECT and SELECT FOR UPDATE disagree
- One UPDATE blocks the whole table
- Long report under Serializable
- How PostgreSQL Serializable works
- Throughput of one hot counter row
- Inserting 10,000 rows one commit each
- Committed data lost after power cut
- Why fsync = off is dangerous
- Do SELECT-only transactions use XIDs
- Two statements sent in one string
- INSERT hangs on another session
- FOR UPDATE on a join locks too much
- Poller misses some rows
- Connection drops during COMMIT
- Many share locks on one row
- Turning off InnoDB deadlock detection
- MySQL Serializable and plain SELECT
- Lowering MySQL isolation to cut lock waits
- An idle MySQL session blocks ALTER
- SELECT FOR UPDATE creates WAL
- Queue length at a hot row
- Guarding a rule across many rows
- Phantoms at PostgreSQL Repeatable Read
- Slowdown from a savepoint per row
- Two locking options compared
- How readers know a row committed
- Deadlock from two concurrent inserts
- Serializable only on one side
- REPLACE INTO removed child rows
- Locked rows come back out of order