HireHireInterview Quizzes › Database Administrator (DBA)

Database Administrator (DBA) Interview Questions

Think you're ready? These are the questions that actually decide Database Administrator (DBA) interviews. Warm up on Easy — then face the Hard round, where 95% of candidates crumble. 79 questions across 3 levels, instant score, completely free.

79Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 20 Qs
Medium
Practical · 29 Qs
Hard
Brutal · 30 Qs
⚡ Take the Database Administrator (DBA) quiz — get your score →

The Database Administrator (DBA) interview questions

Below are the real questions, grouped by difficulty. Expand any one to reveal the correct answer and why — or take the timed quiz for a score you can share. Can you clear the Hard round?

Easy round 20 questions

You add an index on a column that is frequently used in WHERE clauses. What is the typical trade-off?
  • A. SELECTs on it slow down
  • B. Writes (INSERT/UPDATE) become slightly slower ✓
  • C. The table can no longer be queried
  • D. Existing data gets deleted
Correct answer: B. Indexes speed up matching reads but add overhead to writes that must maintain them.
You need to quickly remove ALL rows from a large table and reset it. Which is generally fastest?
  • A. DELETE FROM table
  • B. TRUNCATE TABLE ✓
  • C. UPDATE table SET col = NULL
  • D. SELECT then delete row by row
Correct answer: B. TRUNCATE removes all rows without per-row logging, making it much faster than DELETE.
You have a composite index on (last_name, first_name). Which query can use it most efficiently?
  • A. WHERE first_name = 'Amit'
  • B. WHERE last_name = 'Sharma' ✓
  • C. WHERE email = 'a@b.com'
  • D. WHERE first_name = 'Amit' AND email = 'a@b.com'
Correct answer: B. A composite index is used left-to-right, so a filter on the leading column last_name works.
A foreign key from orders.customer_id to customers.id prevents you from doing what?
  • A. Inserting two orders on the same day
  • B. Inserting an order for a customer that does not exist ✓
  • C. Reading rows from customers
  • D. Creating an index on orders
Correct answer: B. A foreign key enforces referential integrity, blocking orphan rows with no matching parent.
Which condition correctly finds rows where the column 'phone' has no value?
  • A. WHERE phone = NULL
  • B. WHERE phone IS NULL ✓
  • C. WHERE phone = ''
  • D. WHERE phone != 0
Correct answer: B. NULL cannot be compared with =; you must use IS NULL.
At which isolation level can a transaction read another transaction's uncommitted changes (a dirty read)?
  • A. READ UNCOMMITTED ✓
  • B. READ COMMITTED
  • C. REPEATABLE READ
  • D. SERIALIZABLE
Correct answer: A. READ UNCOMMITTED permits dirty reads; higher levels prevent them.
A LEFT JOIN between customers and orders returns customers who have no orders as what?
  • A. Excluded entirely from the result
  • B. Rows with NULLs in the order columns ✓
  • C. Duplicated once per customer
  • D. A query error
Correct answer: B. A LEFT JOIN keeps all left rows, filling unmatched right-side columns with NULL.
You take a full backup weekly and incremental backups daily. To restore to the latest state, you need what?
  • A. Only the most recent incremental
  • B. The full backup plus incrementals applied in order ✓
  • C. Only the full backup
  • D. Any single incremental backup
Correct answer: B. Incrementals only hold changes, so recovery needs the full backup plus each incremental in sequence.
You try to INSERT a row with NULL in the primary key column. What happens?
  • A. It is inserted normally
  • B. It is rejected because a primary key cannot be NULL ✓
  • C. The NULL is converted to 0
  • D. Duplicate keys become allowed
Correct answer: B. A primary key must be unique and NOT NULL, so the insert is rejected.
A money transfer transaction debits one account successfully but the credit step fails. With proper ACID guarantees, what happens?
  • A. Only the debit is kept
  • B. The entire transaction rolls back ✓
  • C. The credit retries forever
  • D. The database crashes
Correct answer: B. Atomicity means the whole transaction succeeds or fully rolls back.
EXPLAIN shows your query doing a full table scan on a million-row table filtered by one column. The most likely fix is what?
  • A. Add an index on that filter column ✓
  • B. Drop the table
  • C. Add more columns to the SELECT list
  • D. Only run VACUUM
Correct answer: A. An index on the filtered column lets the engine avoid scanning every row.
Two transactions each hold a lock the other needs. A modern database detects this and does what?
  • A. Waits forever for both
  • B. Aborts one transaction as the deadlock victim ✓
  • C. Deletes both tables
  • D. Silently ignores the conflict
Correct answer: B. The deadlock detector rolls back one transaction so the other can proceed.
A column 'middle_name' contains NULLs in some rows. How does COUNT(middle_name) compare to COUNT(*)?
  • A. They are always equal
  • B. COUNT(middle_name) is lower because NULLs are skipped ✓
  • C. COUNT(middle_name) is higher
  • D. COUNT(middle_name) is always zero
Correct answer: B. COUNT(column) ignores NULLs, while COUNT(*) counts every row.
To reduce read load on your primary database you set up a read replica. Reads go to the replica; where do writes go?
  • A. To the replica
  • B. To the primary ✓
  • C. Randomly to either
  • D. To neither
Correct answer: B. Writes must go to the primary, which then replicates changes to the read replica.
An application only needs to read data. Following least privilege, you grant it what?
  • A. ALL PRIVILEGES
  • B. Only SELECT ✓
  • C. SELECT and DROP
  • D. Superuser role
Correct answer: B. Least privilege gives only the SELECT permission the read-only app actually needs.
Indexing a 'gender' column that has only two distinct values in a huge table is usually what?
  • A. Highly effective for lookups
  • B. Not very selective, so rarely helpful ✓
  • C. Not allowed by the database
  • D. Faster than the primary key
Correct answer: B. Low-cardinality columns are poorly selective, so an index still matches many rows.
You run SELECT ... FOR UPDATE inside a transaction. What does this do?
  • A. Makes the read run faster
  • B. Locks the selected rows so others cannot modify them until commit ✓
  • C. Deletes the selected rows
  • D. Disables the table's indexes
Correct answer: B. FOR UPDATE places row locks to prevent concurrent modification until the transaction ends.
A customer's full address is repeated in every order row, causing update anomalies. The correct fix is what?
  • A. Add more indexes to the orders table
  • B. Normalize by moving the address into a separate table ✓
  • C. Denormalize the data further
  • D. Drop the address column
Correct answer: B. Normalizing the repeated data into its own table removes redundancy and update anomalies.
Your app opens and closes a brand-new DB connection on every request and slows badly under load. A common fix is what?
  • A. Use a connection pool ✓
  • B. Add more SELECT statements
  • C. Disable all indexes
  • D. Increase each row's size
Correct answer: A. A connection pool reuses established connections, avoiding costly setup on every request.
After a crash, a committed transaction is not lost because the database first recorded its changes where?
  • A. In a temporary table
  • B. In the write-ahead log (WAL) ✓
  • C. In the query cache
  • D. On the client machine
Correct answer: B. Write-ahead logging persists changes before commit, so committed work survives a crash.

Medium round 29 questions

A production query has suddenly become slow. You run EXPLAIN and see a full table scan on a large table where you expected an index to be used. Which is the MOST likely practical cause to investigate first?
  • A. The table's statistics are stale, so the optimizer misestimates row counts ✓
  • B. The database server has run out of disk space
  • C. The primary key was dropped from the table
  • D. The query is using a bind variable instead of a literal
Correct answer: A. Stale statistics commonly cause the optimizer to pick a full scan over an available index, so updating/rebuilding statistics is the first thing to check.
You need to take a backup of a large production database with minimal impact on running transactions and the ability to restore to any point in time. Which backup strategy is most appropriate?
  • A. A nightly full logical export (mysqldump/pg_dump) only
  • B. A full physical backup plus continuous archiving of transaction/redo logs ✓
  • C. Copying the data files while the database is running, without any log archiving
  • D. A weekly cold backup taken while the database is shut down
Correct answer: B. A full physical backup combined with continuous transaction log archiving is what enables point-in-time recovery with low impact.
In a relational database, you want to enforce that every row in an 'orders' table references a valid row in the 'customers' table. Which mechanism enforces this at the database level?
  • A. A CHECK constraint on the orders table
  • B. A UNIQUE index on customers.id
  • C. A FOREIGN KEY constraint on orders.customer_id referencing customers.id ✓
  • D. A trigger that runs only on SELECT
Correct answer: C. A FOREIGN KEY constraint enforces referential integrity by requiring the referenced value to exist in the parent table.
Two transactions are updating the same set of rows in reverse order and the database reports a deadlock, rolling one back. What is the standard, practical way an application should handle this?
  • A. Disable locking on the affected tables
  • B. Increase the deadlock timeout to infinity so it never triggers
  • C. Catch the error and retry the failed transaction, ideally accessing rows in a consistent order ✓
  • D. Switch the database to READ UNCOMMITTED for all sessions
Correct answer: C. Deadlocks are expected under concurrency; the correct handling is to retry the aborted transaction and design consistent lock ordering to reduce recurrence.
A table has columns (a, b, c) and a composite index on (a, b, c). Which of the following WHERE clauses can most effectively use this index?
  • A. WHERE b = 5 AND c = 10
  • B. WHERE a = 1 AND b = 5 ✓
  • C. WHERE c = 10
  • D. WHERE b = 5
Correct answer: B. A composite index is used left-to-right, so predicates on the leading columns (a, then b) can use it, whereas skipping the leading column cannot.
You are asked to grant a reporting user the ability to read data from all current and future tables in a schema, but nothing else. Following the principle of least privilege, which approach is best?
  • A. Grant the user the DBA/superuser role for convenience
  • B. Grant SELECT on the schema's tables and set default privileges so future tables also grant SELECT ✓
  • C. Give the user the application's write account credentials
  • D. Grant ALL PRIVILEGES on the database to the user
Correct answer: B. Granting only SELECT plus default privileges for future tables gives exactly the read access needed without over-permissioning.
A frequently updated table has become bloated and queries are slowing down over time in PostgreSQL. Autovacuum appears to be falling behind. What is the most appropriate action?
  • A. Drop and recreate the table on every deployment
  • B. Tune autovacuum settings (e.g., make it more aggressive) and/or run VACUUM to reclaim space and update visibility ✓
  • C. Disable autovacuum entirely to reduce overhead
  • D. Convert the table to an unlogged table
Correct answer: B. Bloat from dead tuples is addressed by vacuuming; tuning autovacuum to run more aggressively keeps the table healthy without manual intervention.
Your team wants a standby database that automatically stays in sync with the primary and can be promoted if the primary fails. Which feature provides this?
  • A. Scheduled logical dumps restored hourly onto a second server
  • B. Streaming/physical replication from the primary to a standby replica ✓
  • C. A read-only copy refreshed manually once a day
  • D. Partitioning the primary table across two servers
Correct answer: B. Streaming replication continuously ships changes to a standby that can be promoted, providing high availability and failover capability.
You need to add a NOT NULL column with a default value to a very large, busy table in production. What is the safest practical concern to plan around?
  • A. NOT NULL columns cannot have defaults, so the operation will fail
  • B. The ALTER may acquire locks and/or rewrite the table, potentially blocking writes for a long time ✓
  • C. Adding a column always drops all existing indexes
  • D. The change can only be performed while the database is in single-user mode
Correct answer: B. On large tables an ALTER that rewrites data or holds a strong lock can block concurrent access, so DBAs plan for locking and downtime or use online techniques.
A developer reports that a batch job intermittently reads rows another transaction has inserted but not yet committed, causing incorrect totals. Which isolation-related fact is correct?
  • A. READ UNCOMMITTED prevents this by blocking all reads
  • B. Reading uncommitted data is a dirty read, avoided by using READ COMMITTED or higher ✓
  • C. SERIALIZABLE is the only level that allows dirty reads
  • D. Dirty reads only occur when autocommit is enabled
Correct answer: B. Reading another transaction's uncommitted changes is a dirty read, and READ COMMITTED (or stricter) isolation prevents it.
Which isolation level prevents dirty reads but still allows non-repeatable reads?
  • A. Read Uncommitted
  • B. Read Committed ✓
  • C. Repeatable Read
  • D. Serializable
Correct answer: B. Read Committed blocks dirty reads but a re-read within a transaction can still change.
What does a clustered index determine?
  • A. It defines the physical storage order of the table's rows ✓
  • B. It stores a separate copy of all indexed columns only
  • C. It is always non-unique by design
  • D. It can only be built on text columns
Correct answer: A. A clustered index dictates the physical ordering of rows; a table can have only one.
What is a deadlock in a database?
  • A. A query that runs too slowly to finish
  • B. A corrupted index needing a rebuild
  • C. A connection that timed out waiting for the network
  • D. Two or more transactions each waiting on locks the other holds ✓
Correct answer: D. A deadlock is a cyclic wait where transactions block each other indefinitely.
Which backup type captures all changes since the last full backup (cumulative)?
  • A. Transaction log backup
  • B. Incremental backup
  • C. Differential backup ✓
  • D. Full backup
Correct answer: C. A differential backup is cumulative from the last full backup, unlike incremental which is since the last backup of any type.
What is the default transaction isolation level in MySQL's InnoDB engine?
  • A. Repeatable Read ✓
  • B. Read Committed
  • C. Serializable
  • D. Read Uncommitted
Correct answer: A. InnoDB defaults to Repeatable Read, using MVCC snapshots for consistent reads.
What does an execution plan (EXPLAIN) help a DBA do?
  • A. Repair a corrupted table
  • B. Show how a query will be executed so it can be optimized ✓
  • C. Grant privileges to a role
  • D. Compress the table data
Correct answer: B. EXPLAIN reveals the optimizer's chosen access path, joins, and index usage for tuning.
What is a covering index?
  • A. An index that is always clustered
  • B. An index rebuilt after every write
  • C. An index containing all columns a query needs, avoiding table lookups ✓
  • D. An index that spans multiple unrelated tables
Correct answer: C. A covering index satisfies a query entirely from the index, skipping the base-table fetch.
Which situation most benefits from table partitioning?
  • A. Splitting a very large table into segments for better performance and maintenance ✓
  • B. Encrypting sensitive columns automatically
  • C. Removing the need for any indexes
  • D. Guaranteeing ACID across separate servers
Correct answer: A. Partitioning divides huge tables so queries and maintenance touch smaller segments.
In PostgreSQL, what does the VACUUM operation do?
  • A. It rebuilds all foreign keys
  • B. It creates a full backup of the cluster
  • C. It re-encrypts the data files
  • D. It reclaims storage occupied by dead tuples ✓
Correct answer: D. VACUUM removes dead tuples left by MVCC updates/deletes and frees space for reuse.
Point-in-time recovery typically requires which combination?
  • A. Only the latest differential backup
  • B. A full backup plus transaction log / WAL / binlog backups ✓
  • C. A single snapshot with no logs
  • D. Only an index-only scan of the table
Correct answer: B. Replaying transaction logs from a base full backup lets you restore to an exact moment.
How many clustered indexes can a single table have?
  • A. One, because it defines the physical row order ✓
  • B. Unlimited, like non-clustered indexes
  • C. Exactly two, one per storage engine
  • D. None; clustered indexes are not allowed
Correct answer: A. A clustered index determines the physical order of rows, so a table can have at most one.
When does a deadlock occur?
  • A. Two transactions each hold a lock the other needs ✓
  • B. A single query exceeds its timeout limit
  • C. A table has no primary key defined
  • D. Two users read the same row simultaneously
Correct answer: A. A deadlock arises when transactions hold locks and each waits on a lock held by the other.
What is a database view?
  • A. A stored named query that acts as a virtual table ✓
  • B. A physical copy of a table on another disk
  • C. An index that spans multiple columns
  • D. A scheduled job that refreshes statistics
Correct answer: A. A view is a stored query presented as a virtual table, computed on access.
Which is a key difference between TRUNCATE and DELETE?
  • A. TRUNCATE cannot use a WHERE clause and is minimally logged ✓
  • B. TRUNCATE can filter rows with a WHERE clause
  • C. TRUNCATE always fires row-level DELETE triggers
  • D. TRUNCATE is always slower than DELETE
Correct answer: A. TRUNCATE removes all rows without a WHERE clause, is minimally logged, and generally doesn't fire row triggers.
A composite index on (last_name, first_name) can efficiently serve a query filtering only on which column?
  • A. last_name alone ✓
  • B. first_name alone
  • C. neither column individually
  • D. first_name with an unindexed column
Correct answer: A. The leftmost-prefix rule lets the index serve queries on last_name alone, but not first_name alone.
What is the main purpose of a write-ahead log (WAL)?
  • A. Record changes to disk before applying them for durability/recovery ✓
  • B. Cache query results to speed up reads
  • C. Store user login audit history
  • D. Compress old table partitions automatically
Correct answer: A. WAL writes change records durably before the data pages, enabling crash recovery and durability.
How does the HAVING clause differ from WHERE?
  • A. HAVING filters rows after aggregation/grouping ✓
  • B. HAVING filters individual rows before grouping
  • C. HAVING can only be used without GROUP BY
  • D. HAVING sorts the final result set
Correct answer: A. WHERE filters rows before grouping, while HAVING filters groups after aggregation.
Compared with a stored procedure, a scalar SQL function typically what?
  • A. Must return a value and can be used in a query expression ✓
  • B. Cannot return any value to the caller
  • C. Can never be called from another function
  • D. Always performs faster bulk DML operations
Correct answer: A. A scalar function must return a value and can be embedded within SQL expressions, unlike procedures.
What is a benefit of primary-replica replication?
  • A. Offloads read queries and improves availability ✓
  • B. Eliminates the need for any backups
  • C. Guarantees zero replication lag always
  • D. Automatically normalizes the schema
Correct answer: A. Replicas can serve read traffic and provide failover targets, improving scalability and availability.

Hard round 30 questions

A PostgreSQL query that ran in 20ms yesterday now takes 8 seconds. EXPLAIN ANALYZE shows the planner chose a nested-loop join with an inner sequential scan, and the plan node reports `rows=1` estimated vs `rows=480000` actual on the driving table after a large bulk load. Which action most directly addresses the root cause?
  • A. Add a covering index on the join column so the nested loop can seek instead of scan
  • B. Run ANALYZE on the affected table so the planner has fresh cardinality statistics ✓
  • C. Increase work_mem so the hash join spills less to disk
  • D. Set enable_nestloop = off for the session to force a hash join
Correct answer: B. A 1-vs-480000 estimate error after a bulk load is a stale-statistics symptom, so running ANALYZE restores accurate cardinality and lets the optimizer pick the correct join method.
On SQL Server you observe a stored procedure that is fast for most inputs but occasionally times out after a plan recompiles. The cached plan was compiled for a highly selective parameter value but is being reused for a value that matches millions of rows, causing an index seek + key lookup instead of a scan. Which technique specifically neutralizes this parameter-sniffing regression without disabling reuse entirely?
  • A. Add OPTION (RECOMPILE) or OPTIMIZE FOR UNKNOWN to the statement ✓
  • B. Update statistics with FULLSCAN on the underlying table
  • C. Rebuild the nonclustered index to remove fragmentation
  • D. Wrap the query in a transaction at SERIALIZABLE isolation
Correct answer: A. OPTION (RECOMPILE) recompiles per execution using the actual parameter, and OPTIMIZE FOR UNKNOWN uses average density, both directly countering a skewed sniffed plan.
Two application transactions repeatedly deadlock in production. Session A updates rows in table `orders` then `inventory`; session B updates `inventory` then `orders`. Retrying reduces symptoms but the deadlocks recur under load. What is the most robust permanent fix?
  • A. Lower the isolation level of both transactions to READ COMMITTED
  • B. Enforce a consistent lock-acquisition order (always orders then inventory) in both code paths ✓
  • C. Add NOLOCK hints to the SELECT statements inside both transactions
  • D. Increase the deadlock_timeout so the detector waits longer before aborting
Correct answer: B. Deadlocks from a lock cycle are eliminated by imposing a global ordering on resource acquisition so a circular wait can never form; retry logic only masks the recurrence.
In PostgreSQL, `pg_stat_activity` shows an idle-in-transaction session open for 6 hours. Autovacuum is running but dead tuples on a hot table keep climbing and the table is bloating. Why can't autovacuum reclaim the space, and what is the correct immediate action?
  • A. Autovacuum is blocked by a lock; run VACUUM FULL to force reclaiming
  • B. The long transaction holds back the xmin horizon so dead tuples remain visible; terminate that transaction ✓
  • C. Autovacuum cost limits are too low; raise autovacuum_vacuum_cost_limit to catch up
  • D. The table needs a REINDEX because index bloat prevents tuple removal
Correct answer: B. An old open transaction pins the global xmin horizon, so VACUUM cannot remove tuples still potentially visible to it; ending that transaction lets cleanup proceed.
You must choose an isolation level for a financial ledger that debits one account and credits another, where the invariant is that total balance across a set of accounts never goes negative even under concurrent transfers. Under PostgreSQL, which level prevents the write-skew anomaly that lets two concurrent transactions each pass the check and jointly violate the invariant?
  • A. READ COMMITTED with SELECT ... FOR UPDATE on both rows
  • B. REPEATABLE READ (snapshot isolation)
  • C. SERIALIZABLE ✓
  • D. READ COMMITTED with an advisory lock on the account pair
Correct answer: C. Write skew is a snapshot-isolation anomaly that REPEATABLE READ permits; only SERIALIZABLE (SSI) detects the dangerous read/write dependency and aborts one transaction, though explicit row locking can also work it is not the isolation-level answer asked for.
After an automated standby promotion, application reads begin failing with errors like 'cannot execute UPDATE in a read-only transaction' intermittently, while other reads succeed. The connection string points to a DNS name fronting both nodes. What is the most likely root cause?
  • A. Replication lag on the new primary is serving stale reads
  • B. The old primary was not fully demoted and connections are load-balanced across a still-read-only node ✓
  • C. The new primary's statistics are stale after promotion
  • D. Synchronous commit is waiting on a standby that no longer exists
Correct answer: B. The 'read-only transaction' error means some connections still land on a node in recovery/standby mode, indicating split routing where the old node wasn't demoted or removed from the pool.
An overnight alert fires: the primary's data volume hit 100% and writes are failing. You have a synchronous standby that is healthy. Ordering the response, which sequence best balances availability and data safety?
  • A. Immediately run VACUUM FULL on the largest table to reclaim space on the primary
  • B. Delete old WAL segments manually with rm to free space, then continue
  • C. Fail over to the healthy standby to restore writes, then root-cause the primary's disk (WAL accumulation, unrotated logs, bloat) offline ✓
  • D. Extend the volume online and take no further action since space is restored
Correct answer: C. Failing over restores service safely without risky in-place operations on a full disk, and manually deleting WAL can corrupt recovery/replication; root-cause and retention fixes follow.
A gp3 EBS volume backs an RDS PostgreSQL instance. Monitoring shows disk queue depth climbing and read latency spiking during a nightly batch, yet CPU is at 30% and the buffer cache hit ratio is 99%. You provisioned 12000 IOPS but throughput sits pinned at 125 MiB/s. What is the actual bottleneck?
  • A. The instance is CPU-starved and needs a larger instance class
  • B. The IOPS ceiling is being hit and more provisioned IOPS is required
  • C. gp3's default throughput (125 MiB/s) is saturated; provision higher throughput separately from IOPS ✓
  • D. The buffer cache is too small, forcing physical reads
Correct answer: C. gp3 decouples IOPS from throughput, and the default 125 MiB/s cap is a common hidden ceiling for large sequential batch I/O even when IOPS headroom remains.
You are designing HA/DR for a system with RPO = 0 and RTO = 60 seconds. Which architecture satisfies both constraints?
  • A. Asynchronous cross-region replica with automated failover
  • B. Synchronous replication to a standby in another AZ with automatic failover and split-brain fencing ✓
  • C. Nightly full backups plus WAL archiving to object storage for PITR
  • D. Semi-synchronous replication to a cross-region replica
Correct answer: B. RPO=0 mandates synchronous commit (no acknowledged-but-lost writes), and a same-region cross-AZ synchronous standby with fast fenced failover meets the 60-second RTO, whereas async/PITR permit data loss.
In an Oracle RAC cluster, AWR shows high 'gc buffer busy acquire' and 'gc cr block busy' waits concentrated on one hot index's right-most leaf block during heavy concurrent inserts of sequential keys. Which change most directly reduces the interconnect contention?
  • A. Increase the interconnect MTU (jumbo frames)
  • B. Convert the index to a reverse-key or hash-partitioned global index to spread inserts across blocks ✓
  • C. Raise the buffer cache size on all instances
  • D. Increase the ASM rebalance power limit
Correct answer: B. Sequential-key inserts create a right-hand-index hot block pinging across the interconnect; a reverse-key or hash-partitioned index distributes inserts across many blocks, eliminating the single hot leaf.
In PostgreSQL MVCC, what does transaction ID (XID) wraparound cause if autovacuum fails to run?
  • A. Old committed rows can appear to be in the future and become invisible, risking data loss ✓
  • B. Indexes silently rebuild themselves
  • C. Autovacuum permanently disables all writes
  • D. Connection memory usage doubles
Correct answer: A. Unfrozen XIDs wrapping past the current counter make old rows look future-dated and unreadable, a catastrophic data-loss risk.
What happens during 'lock escalation' in SQL Server?
  • A. Row locks are demoted to weaker shared locks
  • B. Two transactions swap their lock queues
  • C. Many fine-grained row/page locks are converted to a single coarser table lock ✓
  • D. Locks are replicated to a standby server
Correct answer: C. SQL Server escalates numerous granular locks into one table lock to reduce lock-manager memory overhead.
Why can a query using LIKE '%abc' (leading wildcard) not use a B-tree index efficiently?
  • A. The optimizer always ignores every index for LIKE
  • B. A leading '%' prevents an ordered prefix seek, forcing a scan ✓
  • C. LIKE can never use an index under any condition
  • D. The wildcard corrupts the index structure
Correct answer: B. B-tree ordering is by prefix, so an unknown leading portion prevents a seek and forces a full scan.
From a DBA's perspective, what is the primary purpose of a database connection pool?
  • A. It encrypts every SQL statement in transit
  • B. It automatically shards the database
  • C. It guarantees serializable isolation
  • D. It reuses established connections to avoid connect/auth overhead and cap concurrency ✓
Correct answer: D. Pooling recycles authenticated connections, cutting handshake cost and bounding server load.
In MySQL replication, what does GTID (Global Transaction Identifier) primarily improve?
  • A. It simplifies failover and consistency by uniquely identifying each transaction across servers ✓
  • B. It compresses the binary logs on disk
  • C. It replaces the need for a primary key
  • D. It encrypts replication traffic by default
Correct answer: A. GTIDs track transactions globally so replicas and failover no longer depend on binlog file/position coordinates.
Which statement about the CAP theorem holds during a network partition in a distributed database?
  • A. You can fully keep both consistency and availability
  • B. Partitions never affect a distributed database
  • C. During a partition you must choose between consistency and availability ✓
  • D. CAP applies only to single-node databases
Correct answer: C. When a partition occurs, a system can preserve either consistency or availability, not both.
A query suddenly slows after a large data load, yet its plan looks unchanged. What is the most likely DBA cause?
  • A. The table's primary key was silently dropped
  • B. Stale statistics led the optimizer to a poor plan from bad cardinality estimates ✓
  • C. The database switched isolation levels on its own
  • D. The network MTU changed
Correct answer: B. Outdated statistics after a big load cause cardinality misestimation and suboptimal plan choices.
In PostgreSQL, which index type is best suited for full-text search and JSONB containment queries?
  • A. GIN ✓
  • B. B-tree
  • C. Hash
  • D. BRIN
Correct answer: A. GIN (Generalized Inverted Index) is designed for composite values like tsvectors and JSONB keys.
'Write amplification' and periodic compaction are characteristic performance concerns of which storage design?
  • A. Traditional heap tables
  • B. Classic B-tree page storage
  • C. ISAM flat files
  • D. LSM-tree engines like RocksDB or Cassandra ✓
Correct answer: D. Log-structured merge trees rewrite data during compaction, producing write amplification.
To add a NOT NULL column with a constant default to a huge table in PostgreSQL 11+ with minimal locking, you rely on what?
  • A. A mandatory full table rewrite under an exclusive lock
  • B. Disabling autovacuum during the change
  • C. The optimization that stores the constant default in catalog metadata, avoiding a full rewrite ✓
  • D. Converting the table to an unlogged table first
Correct answer: C. Since v11 a constant default is recorded in catalog metadata, so existing rows aren't physically rewritten.
In a database using MVCC (e.g., PostgreSQL), how are readers and writers coordinated?
  • A. Readers see a snapshot and don't block writers, who create new row versions ✓
  • B. Readers always acquire exclusive locks that block writers
  • C. Writers overwrite rows in place and block all readers
  • D. All access is serialized through a single global lock
Correct answer: A. MVCC gives readers a consistent snapshot while writers create new tuple versions, so reads and writes don't block each other.
Which index structure is optimized purely for equality lookups rather than range scans?
  • A. Hash index ✓
  • B. B-tree index
  • C. GiST index
  • D. Clustered index
Correct answer: A. Hash indexes support fast equality comparisons but cannot serve ordered range queries.
In query optimization, what does a cardinality estimate refer to?
  • A. The predicted number of rows a plan step will produce ✓
  • B. The number of CPU cores assigned to the query
  • C. The count of indexes available on the table
  • D. The total disk size of the table in bytes
Correct answer: A. Cardinality estimation predicts the row count at each plan step, which drives the optimizer's plan choice.
Per the ANSI SQL standard, which isolation level prevents phantom reads?
  • A. SERIALIZABLE ✓
  • B. READ COMMITTED
  • C. READ UNCOMMITTED
  • D. REPEATABLE READ
Correct answer: A. In the ANSI standard, only SERIALIZABLE prevents phantom reads; REPEATABLE READ still permits them.
How does horizontal sharding differ from table partitioning?
  • A. Sharding distributes data across separate database servers/nodes ✓
  • B. Sharding splits data only within a single server's storage
  • C. Sharding never changes where data physically lives
  • D. Sharding only applies to in-memory temporary tables
Correct answer: A. Sharding spreads data across independent nodes, whereas partitioning typically divides data within one server.
In a two-phase commit protocol, what does the prepare phase ensure?
  • A. All participants confirm they can commit before any commits ✓
  • B. The coordinator commits immediately without asking participants
  • C. Each node commits independently and reconciles later
  • D. Only the coordinator's local changes are durable
Correct answer: A. The prepare (voting) phase has every participant durably promise it can commit before the commit phase proceeds.
In PostgreSQL, why is VACUUM primarily needed?
  • A. To reclaim space from dead tuples left by MVCC updates/deletes ✓
  • B. To rebuild every index from scratch on each run
  • C. To encrypt tables storing sensitive data
  • D. To flush the write-ahead log to a backup server
Correct answer: A. MVCC leaves dead tuples behind; VACUUM reclaims that space and prevents transaction-ID wraparound.
How does a covering index improve a query?
  • A. It contains all columns the query needs, avoiding table lookups ✓
  • B. It forces a full table scan for accuracy
  • C. It stores data in a compressed archive format
  • D. It replaces the table's primary key constraint
Correct answer: A. A covering index includes every column the query references, so the query is answered index-only without hitting the table.
Under the CAP theorem, during a network partition a distributed database must choose between which two properties?
  • A. Consistency and availability ✓
  • B. Concurrency and atomicity
  • C. Durability and isolation
  • D. Latency and throughput
Correct answer: A. CAP states that under a partition a system must trade off between consistency and availability.
How is point-in-time recovery (PITR) achieved?
  • A. Restore a base backup and replay transaction logs to a target time ✓
  • B. Keep only the single latest full backup
  • C. Replicate the database to a second region in real time
  • D. Export all tables to CSV every hour
Correct answer: A. PITR restores a base backup and then replays archived transaction/WAL logs up to the desired moment.

Prep for another role

Questions are original, written and independently verified for HireHire's role interview quizzes. They reflect the kind of knowledge Database Administrator (DBA) interviews test, not any specific company's questions. HireHire maps live tech & IT jobs across India, updated regularly. Last updated: August 2026.