All jobs / Database administrator / Performance
Database administrator interview question · 0–1 years
A developer flags the scan in a code review and asks for an index before merging.
The plan shows a full table scan on a lookup table of about two hundred rows. Problem?
The strongest answer
Almost certainly not — for a tiny table a scan is cheaper than an index seek, so I look at the operators where the actual cost is
Why it works
Exactly — scans are not evil; the planner picks the cheaper path for a table that fits in a few pages.
What a good answer covers
- Small scans are cheap.
- Cost, not operator name.
- Do not index what is never sought.
- Hints are a last resort.
Answers that fall short
- Close, but not the strongest: Probably fine, but I would add an index anyway to be safe
An index the planner will ignore is pure write cost. - Weak: Yes, any table scan in a plan means something is wrong
Plans are about cost, and a small scan is cheap. - Red flag: Yes — I would force an index hint so the optimiser stops scanning
Hints that override a correct decision make the query slower and fragile.
Who gets asked this
More Performance questions
- What are table statistics and why should a DBA care about them?
- Does the column order in a composite index matter?
- You index a status column that has three possible values and the query is no faster. Why?
- Dozens of sessions are waiting and the app has slowed to a crawl. How do you find the culprit?
- The application logs show deadlocks a few times a day. What do you do?
- Several sessions sit “idle in transaction” for hours. Why does that matter and what do you do?
- A query that ran in milliseconds now takes minutes, right after a large data load. First suspect?
- The database shows thousands of identical tiny queries per page load. What is happening and what do you…