SELECT orders.order_date, orders.customer_numb
FROM orders INNER JOIN order_lines ON orders.order_numb = order_lines.order_numb
WHERE order_lines.isbn = '0-131-4966-9';
and here it is rewritten using a subquery:
SELECT order_date, customer_numb
FROM orders
WHERE order_numb IN (SELECT order_numb
FROM order_lines
WHERE isbn = '0-131-4966-9')
Assume that the tables orders and order_lines each have 500,000 rows/tuples.
Assume (somewhat artificially) that RAM can hold 200 rows and devotes half of that to reading one table and half to reading the other table and has "other places" to store the subquery/query results.
(i) How many reads from the hard drive will the original query take?
(ii) How many reads from the hard drive would the rewritten query take?