CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ
A table has 1,000,000 rows in 10,000 blocks. A range predicate selects 20% of the rows, which are spread evenly across the table. There is an UNCLUSTERED B+ tree on the predicate column. Which plan is likely cheapest?
- A. The unclustered index, because it reads only the 200,000 matching rows and nothing else
- B. A full table scan, because the index would cost one random block read per matching row
- C. A hash index lookup on the same column, built on the fly
- D. The index for half the range and a scan for the rest
Correct answer: B. A full table scan, because the index would cost one random block read per matching row
200,000 matching rows through an unclustered index means up to 200,000 random block reads, far more than scanning all 10,000 blocks sequentially. Unclustered indexes pay off only for highly selective predicates.
More DBMS and SQL questions
- Table T(a, b, c) has a composite B+ tree index on (a, b), and the query is SELECT b FROM T WHERE a = 5. What is the main benefit of this…
- In extendible hashing, the global depth is 3 and a full bucket with local depth 2 must split on an insert. What happens?
- R(Emp, Skill, Lang) satisfies Emp ↠ Skill (so also Emp ↠ Lang), and it is decomposed into the 4NF relations (Emp, Skill) and (Emp, Lang)…
- R(a) = {1, 2, 3} and S(a) = {2, 3, 3, 4} (S is a bag). How many rows does SELECT FROM R FULL OUTER JOIN S ON R.a = S.a return? (Checked in…
- A relation has 6 attributes. What is the largest possible number of candidate keys it can have under some set of functional dependencies?
- In multiple-granularity locking, how many of these lock-mode pairs (held, requested) on the same node are compatible? IS–IX, IX–IX, S–IX…