Computer Science Homework Solutions
Problem
#135087

Compare the given select queries in terms of the number of hard drive reads.

Here's a query:

     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?


Solution Summary

Apart from computing the number of hard drive reads in both the cases, solution briefly explains why/how these numbers are different.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$19.95)
Included in Download
  • Plain text response
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Query Results - Why wont this query give any results (using the week 2 lecture database)? SELECT orders.order_numb, customers.customer_last_name FROM customers INNER JOIN orders ON customers.customer_numb = cus ...
  • PQ #1 - I have a query that starts with the line: SELECT books.isbn, order_lines.isbn ...why would I want to see isbns from two different tables? What sort of query would warrant that - an inne ...
  • Query Results - How come I get so many Smiths in this query (using the Week 2 lecture database)? There's only 26 orders and 4 customers named Smith. Yet I get 104 rows as a result? SELECT orders.order_numb, custom ...
  • Access 2000 Database - Use the attached WEEK2_ACCESS2000.mdb database I just need the SQL code, which can be cut and pasted into a word document. 1. Perform an inner join between the BOOKS table and the ORDER_LINE ...
  • Database Coding - 1. Using the order_lines table from the database from lecture 2, write the SQL that will give the Min and Max values of the column "cost_each" 2. Using the week 2 homework database, show each cus ...
Browse