Scaling Reads medium
What is an 'Index Only Scan' (Covering Index) and why is it fast?
- A It scans the whole table.
- B The index contains all the columns requested by the query, so the database never needs to look up the actual table row (Heap).
- C It uses only one CPU core.
- D It skips the index.
Answer: B. The index contains all the columns requested by the query, so the database never needs to look up the actual table row (Heap).
If you `SELECT email FROM Users WHERE id=5`, and you have an index on `(id, email)`, the DB gets the answer directly from the B-Tree. This saves a massive amount of random disk I/O.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In a caching system, what is a 'Cache Miss'?
- Why is `SELECT * FROM Users` generally discouraged in high-performance applications compared to `SELECT name, email FROM Users`?
- You have users all over the world downloading large images from your server in New York. Users in Australia complain it is slow. What solves this?
- What is the main downside of reading from a Read Replica instead of the Primary database?
- You have maximized the RAM on your single database server, but it's still too slow. You decide to add 10 more servers to share the load. What is this called?
- You have 5 Read Replicas. How does the application know which one to ask for data?