Given Relation:
Sailors (sid: integer, sname: string, rating: integer, age: real)
Reserves (sid: integer, bid: integer, day: dates, rname: string)
Query
SELECT *
FROM Reserves R, Sailors S
WHERE R.sid=S.sid
Assume:
M pages of R, pR tuples per page (i.e., number of tuples of R = M * pR)
N pages of S, pS tuples per page (i.e., number of tuples of S = N * pS)
Cost is the number of I/Os (ignore the output cost)
Algorithm for the query
foreach tuple r in R do
foreach tuple s in S do
if ri == sj then add <r, s> to result
Cost
Scan of outer + for each tuple of outer, scan of inner relation.
Cost = M + pR * M * N I/Os
I am confused with the final result for the cost. If we were to scan every tuple in R and then for each r, scan every tuple in S then wouldn't the final cost be R*S = M*pR*N*pS ? (R = M * pR , S = N * pS). I'm not sure why there is an addition symbol. Does I/O only account for pages? and not records?