Question 71
HardWhy is a covering index fast for SELECT name FROM users WHERE email = ?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
DBMS
Why is a covering index fast for SELECT name FROM users WHERE email = ?
An index on (email, name) answers the query without touching the table
It removes the WHERE clause
It stores the whole table twice
It caches the result
Sign up free to see the answer and a step-by-step explanation.
What is the downside of indexing every column of a table?
The table cannot be joined
Writes become slow and storage grows, while many indexes are never used
Reads become slower
Queries return wrong answers
Sign up free to see the answer and a step-by-step explanation.
Which index type does PostgreSQL use for full-text search and arrays?
Bitmap only
B+ tree only
Hash only
GIN (generalised inverted index)
Sign up free to see the answer and a step-by-step explanation.
A query uses WHERE LOWER(email) = '[email protected]'. What index helps?
An expression (functional) index on LOWER(email)
No index can help
An index on email
An index on LOWER
Sign up free to see the answer and a step-by-step explanation.
A data file sorted on emp_id has 50,000 blocks. A sparse primary index stores one entry per block. Why is this enough to find any employee?
It is not enough
Because every key is indexed
Because the file is sorted, the entry for the block whose first key is ≤ the target tells you exactly which block to read
Because blocks are hashed
Sign up free to see the answer and a step-by-step explanation.
A table has a clustered index on order_date. Which query benefits most?
WHERE amount > 1000
WHERE customer_id = 7
WHERE status = 'open'
WHERE order_date BETWEEN '2024-01-01' AND '2024-01-31'
Sign up free to see the answer and a step-by-step explanation.
What does an LSM tree (used by Cassandra and RocksDB) optimise for?
Fast single-row updates in place
Small memory use
High write throughput, by buffering writes in memory and merging sorted files on disk
Very fast range deletes only
Sign up free to see the answer and a step-by-step explanation.
Why does deleting many rows not always shrink a B+ tree index's size on disk?
Deleted rows are kept forever
Pages are often left partly empty rather than merged immediately
The index is compressed
Indexes never change
Sign up free to see the answer and a step-by-step explanation.
Which is the best choice for an index on a UUID primary key that is generated randomly?
A hash index on every column
No index at all
Understand that random inserts scatter across the B+ tree, causing page splits; time-ordered IDs reduce this
A bitmap index
Sign up free to see the answer and a step-by-step explanation.
How many disk reads does a B+ tree of height 4 need to find a record, if no pages are cached and each node is one page?
5 (4 index levels + 1 data page)
2
4
1
Sign up free to see the answer and a step-by-step explanation.