GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 69

Selection pushdown and duplicate courses

Database Management Systems · Indexing, Storage & Query Processing · Full GATE CSE 2006 paper

GATE 2006, Q69 2 marks · MCQ
Report issue

Indexing, Storage & Query Processing

Question 69, GATE 2006: Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student, have no nulls, foreign keys or additional constraints. Amounts 6000,7000,8000,9000,10000 are each paid by 20% of students.
Both plans list courses of students paying more than x. Plan 1 sequentially scans paid, selects amount>x, probes enrolled's student index for an indexed nested-loop join, then projects course. Plan 2 scans all paid and performs the same indexed join first, then selects amount>x and projects course. Projection does not request DISTINCT. A disk seek costs 4 ms, transfer rate is 300 MB/s, and checking amount>x costs 10 μs per tuple. Which statement holds?
Options:
(A) The plans do not return identical rows for every database
(B) Plan 1 may list a course more than once
(C) At x=5000 Plan 1 is faster for every database
(D) At x=9000 Plan 1 is slower for every database
Question 69, GATE 2006: Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student, have no nulls, foreign keys or additional constraints. Amounts 6000,7000,8000,9000,10000 are each paid by 20% of students.
Both plans list courses of students paying more than x. Plan 1 sequentially scans paid, selects amount>x, probes enrolled's student index for an indexed nested-loop join, then projects course. Plan 2 scans all paid and performs the same indexed join first, then selects amount>x and projects course. Projection does not request DISTINCT. A disk seek costs 4 ms, transfer rate is 300 MB/s, and checking amount>x costs 10 μs per tuple. Which statement holds?
Options:
(A) The plans do not return identical rows for every database
(B) Plan 1 may list a course more than once
(C) At x=5000 Plan 1 is faster for every database
(D) At x=9000 Plan 1 is slower for every database
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Both plans select the same matching paid/enrolled tuples: pushing a predicate on paid.amount below the join preserves the result. Projection without DISTINCT can output the same course for two different qualifying students, so B is true under SQL bag semantics.

2. The enrolled key is (student,course), not course. C is not universal: at x=5000 all paid rows pass, and with no enrollments Plan 2 has no joined rows to test while Plan 1 still tests paid rows.

3. D is not universal either: at x=9000 Plan 1 can avoid 80% of index probes, making it faster on ordinary populated instances. Seek and transfer constants do not turn either universal performance claim into a theorem.

4. The plans/options continue on page 11.

5. Teaching check: Pushing a filter before a join can reduce work, but a universal speed claim needs more than a selectivity estimate. Course is not a key of the join output, so two qualifying students in the same course produce repeated course values after projection without DISTINCT.

Original paper, page 10