Skip to content

ISRO Scientist/Engineer CSE 2017Databases › Not yet assigned to a topic

ISRO Scientist/Engineer CSE 2017 PYQ: Consider the following query : $SELECT$ E.eno, $COUNT(*)$ $FROM$ Employees E $GROUP\, BY$ E.eno If an index…

Consider the following query :

$SELECT$ E.eno, $COUNT(*)$
$FROM$ Employees E
$GROUP\, BY$ E.eno

If an index on $eno$ is available, the query can be answered by scanning only the index if

  1. A
    the index is only hash and clustered
  2. B
    the index is only $B+$ tree and clustered
  3. C
    index can be hash or $B+$ tree and clustered or non-clustered
  4. D
    index can be hash or $B+$ tree and clustered
    Correct answer

Answer

(D) index can be hash or $B+$ tree and clustered

Approach

For the query SELECT E.eno, COUNT(*) FROM Employees E GROUP BY E.eno, an index-only scan requires that all tuples of each group be reachable from the index alone. A clustered index on eno (whether hash or B+ tree) stores/orders entries by eno, so scanning the index directly yields the count per eno without touching the base table. A non-clustered index stores row pointers, so counting requires probing the data file and is not a pure index-only scan. Hence the index must be hash or B+ tree AND clustered, i.e., option D. Options A and B wrongly restrict the index type, and option C wrongly adds non-clustered.

Reviewed by ISRO IQ Editorial Team.