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 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. ...
Solution Summary
Apart from computing the number of hard drive reads in both the cases, solution briefly explains why/how these numbers are different.
... information to another query(like a DML or a select). Both queries can be used in Where clause and having clause of a parent query. Comparison operators when ...
... My query: SELECT * FROM Students WHERE GPA < 3.0 and Year ... we only need to tweak your queries a bit ... are using "Year like" when you should use an "=" comparison. ...
... AutoCalc in the Tools group., and then select Sum from the list. j. Close the PivotTable field List. Compare the PivotTable to Figure 5.42. Save the query. ...
Structured Query Language (SQL) Preliminaries. ... 3. Compare the join and the SQL subquery. ... 5. Write the SELECT statement to display all the columns of the STUDENT ...
... the second most influential in choosing a nursing home PHYSICIAN NURSING HOME COMPARE WEBSITE NURSE or ... The response addresses the queries posted in 475 ...
... addresses the queries posted in 550 words with references. Strategies 1. Three Strategies and their comparison: Wal-Mart Strategies 2. The selected company is ...
... Construct the following SQL queries for this relational ... different databases handle date comparisons differently ...SELECT count(*) FROM Accident WHERE (date >= 1/1 ...
... for set membership, make set comparisons, and determine ... borrower Where customer-name in (select coustomer-name ... Writing queries in SQL is usually much easier ...
... 3. In order to compare within vendors to see whether ... result using the select operator to select the rows ... 6. Let's project the part # since the query asks for ...
... Additionally, compare and contrast the four principles of ... The response addresses the queries posted in 1143 Words ... proposal types, I have selected the 'flexible ...