Purchase Solution

Comparison of two select queries

Not what you're looking for?

Ask Custom Question

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?

Purchase this Solution

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 Preview

Total no. of records in each table = 500,000
No. of groups of 100 rows in each table (since we read 100 rows at a time) = 500,000 / 100 = 5,000

(i) In the original query each record of first table has to be compared against every record of second table. ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Javscript Basics

Quiz on basics of javascript programming language.

C++ Operators

This quiz tests a student's knowledge about C++ operators.