Query Processing and Optimization
Query Processing and Optimization
Query Processing and Optimization
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Unnesting Nested Queries<br />
• Uncorrelated sub-queries with aggregates.<br />
• Most systems would compute the average only once.<br />
SELECT ssn<br />
FROM emp<br />
WHERE salary > (SELECT AVG(salary) FROM emp)<br />
• Uncorrelated sub-queries without aggregates.<br />
SELECT ssn<br />
FROM emp<br />
WHERE dept IN (SELECT dept FROM techdept)<br />
• Some systems may not use emp's index on dept, so a<br />
transformation is desirable.<br />
SELECT ssn<br />
FROM emp, techdept<br />
WHERE emp.dept = techdept.dept<br />
When is this<br />
acceptable?<br />
51