Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

scalar subqueries vs. joins

286397Apr 9 2003 — edited Apr 15 2003
Hi,

is someone able to tell me something about the impact on performance of scalar subqueries in select list?
I found that scalar subqueries are processed faster than joins but don't understand why.
E.g. first statement:
select e.ename, d.deptno,
(select dname from dept d where d.deptno=e.deptno) dname from emp e
where e.deptno =10;

Second statement:
select e.ename, d.deptno, d.dname
from emp e, dept.d
where e.deptno=d.deptno and d.deptno=10;

The optimizer calculates the first statement using a full table scan on emp, while the second statement using a nested loop join.

First statement is executed faster. I found also that the first staement is executed more for throughput, the second for answer time.

This is the behavior not only if there are thousands of lines in emp but also in real life applications.

Regards Frank
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2003
Added on Apr 9 2003
4 comments
396 views