CS FundamentalsVery hardGATE CS (PYQ pattern)
A table has 100,000 rows in 2500 pages, and a predicate selects 3% of the rows, which are spread uniformly at random over the pages. An unclustered B+ tree of height 3 (3 reads to the first leaf, leaf scanning ignored) is used, but the matching record ids are first sorted by page so each needed page is read only once. What is the expected cost of this plan, and is it cheaper than the 2500-page full scan?
- A. about 3003 reads; dearer
- B. about 1750 reads; cheaper
- C. about 2503 reads; dearer
- D. about 78 reads; cheaper
Correct answer: B. about 1750 reads; cheaper
3000 matching rows hit each page with probability 1 - (1 - 1/2500)^3000 = 1 - e^-1.2 = 0.699, so about 1747 distinct pages; plus 3 index reads gives about 1750 < 2500. Without sorting, each row costs a read: 3003. 78 assumes the matches are packed contiguously (clustered).
More DBMS and SQL questions
- A heap file stores 1,000,000 fixed-length records of 150 bytes in 8192-byte blocks with no block header; records do not span blocks. How…
- R(A, B, C, D, E, F) has the functional dependencies BC → D, F → D, F → C, C → D, E → C, DC → E. Counting only the listed dependencies, how…
- R(A, B, C, D, E, F) has the functional dependencies B → E, E → D, B → E, EB → A, A → F. Decompose R into BCNF by this procedure: while…
- R(A, B, C, D, E, F) has FDs A → B, B → C, C → A, AD → E, E → F. How many candidate keys does R have?
- A relation R(A, B, C) holds the tuples (1,x,10), (1,x,20), (1,y,10), (1,y,20), (2,x,10), (2,y,20). Which statement is correct?
- R(A, B, C, D, E) has FDs A → B, C → D, BD → E. How many of the following decompositions are lossless-join? (1) (AB) , (CD) , (ACE) (2)…