Suppose that we have an application that requires tuples belongs to the natural
ID: 3548777 • Letter: S
Question
Suppose that we have an application that requires tuples belongs to the natural join of relations r(AB) and s(BC) to be scanned and some operation f to be performed on those tuples. The operation f cannot be coded in SQL and therefore JDBC must be used. Consider following options for a JDBC program.
option(A):Join is done by the database server. The query to computer r|x|s is executed once before entering the loop. Each iteration of the loop executes the operation f once.
option(B):Join is done in Java. A select statement on one relation is executed once before entering the outer loop and for each tuple of the outer loop another select statement on the other relation is executed once before each time the inner loop is entered. In the inner loop the condition r.B == s.B is verified and for tuples satisfying this condition f is executed.
ASSUMING THE FOLLOWING, ESTIMATE THE COST OF EXECUTING THE PROGRAM USING OPTION (A) and (B)
Explanation / Answer
Option A:
cost = 10000 * 0.3 + 15000 = 18000 milliseconds
Option B:
cost = 500 + 1000 * 500 + 10000 * 0.3 = 503500 milliseconds
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.