Have an employee table set up like this:
tbl_employees
--------------------
employee_id
manager_id
org_id
Manager_id is the employee_id of the employee's manager
We are trying to do an update on another table that controls some organizational assignments, the other table is set up like this:
tbl_assigned_orgs
--------------------
employee_id
start_date
end_date
org_id
Query looks like this:
update tbl_assigned_orgs set end_date = sysdate where
employee_id = president_emp_id
and sysdate > start_date and end_date is null
and org_id not in (
select distint org_id from tbl_employees
where org_id is not null
start with employee_id = tbl_assigned_orgs.employee_id connect by prior employee_id = manager_emp_id
)
We solved the "issue" we are having in our development and production environments by issuing a "Compute Statistics" command before running this query, in dev/test environments this query runs in < 15 minutes, in our production environment, however, this query runs between 3 and 6 HOURS...
The employee table has about 8,000 rows in it.
Any better ideas on how to get the same results, or at least speed up this query?
ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
tbl_employees
--------------------
employee_id
manager_id
org_id
Manager_id is the employee_id of the employee's manager
We are trying to do an update on another table that controls some organizational assignments, the other table is set up like this:
tbl_assigned_orgs
--------------------
employee_id
start_date
end_date
org_id
Query looks like this:
update tbl_assigned_orgs set end_date = sysdate where
employee_id = president_emp_id
and sysdate > start_date and end_date is null
and org_id not in (
select distint org_id from tbl_employees
where org_id is not null
start with employee_id = tbl_assigned_orgs.employee_id connect by prior employee_id = manager_emp_id
)
We solved the "issue" we are having in our development and production environments by issuing a "Compute Statistics" command before running this query, in dev/test environments this query runs in < 15 minutes, in our production environment, however, this query runs between 3 and 6 HOURS...
The employee table has about 8,000 rows in it.
Any better ideas on how to get the same results, or at least speed up this query?
ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise