Consider the class Person with an additional attribute, age. Write an OQL query that, for each age, produces a count of people of this age. Use two methods: with the GROUP BY clause and without it (using a nested query in SELECT). Describe a plausible query evaluation strategy in each case and explain which query will run faster.

What will be an ideal response?


SELECT DISTINCT age: P.age,
count: count (SELECT P2.Id
FROM PersonExt P2
WHERE P2.age = P.age)

FROM PersonExt P

SELECT DISTINCT age: P.age, count: count(P2.Id)
FROM PersonExt P, PersonExt P2
WHERE P.age = P2.age
GROUP BY P.age


In the ?rst case, the DBMS is unlikely to ?gure out that it needs to count the Ids, so it would probably sort (or hash) the extent of the class Person on age and then for each value of this attribute it would execute the subquery. This would result in another access to the extent of the class Person.
In the second case, the ODBMS will know that it has to sort the class Person on age and then it will compute the result in one scan of the extent of that class.

Computer Science & Information Technology

You might also like to view...

Microsoft Office applications use a(n) ________ that consists of windows, dialog boxes, toolbars, icons, and menus?

A) operating systems B) work area C) graphical layout D) graphical user Interface

Computer Science & Information Technology

_______ describes how data should look on a web site; ______ describes data being exchanged between business partners.

A. EDI; HTML B. EDI; XML C. HTML; XML D. XML; HTML

Computer Science & Information Technology