Skip to Main Content

Oracle Database Discussions

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Best practice query

Nic PilotNov 21 2021

Hi,
For a while I'm questioning myself about a best practice query for performance.
I've 2 tables.
EMPLOYEES and DEPARTMENTS
The EMPLOYEES table can contains millions of records.

Which query is better for performance ?

Query 1

Select t1.emp_id, t1.emp_name, t2.dept_name
from EMPLOYEES t1, DEPARTMENTS t2
where t1.dept_id = t2.dept_id
order by t1.emp_name

Query 2

Select emp_id, emp_name, (select mypackage.get_dept_name(dept_id) from dual) as dept_name
from EMPLOYEES
order by emp_name

Comments

Post Details

Added on Nov 21 2021
6 comments
250 views