SQL Delete Statement taking a long time to run (oracle)

15 Views Asked by At

In a timesheet system, there is the charge tree where we enter projects for employees to add to the timesheet. We are wanting to start cleaning this up on old projects that have ended, etc.

This is the statement, I have re-written it in many different ways but it always take a long time, even when there are no record to delete.

I am self taught so bear with me please, I am almost positive it has to do with the concat(mo.bld_proj_id,'%') like ud2.udt02_name portion

(here is an example of the two fields and how the data looks that I am trying to compare. Table Data

    DELETE FROM tc_0002.charge_branch_charge@etime ctree
WHERE ctree.charge_cd IN
            (SELECT ud2.udt02_id
             FROM tc_0002.udt02@etime ud2
             INNER JOIN deltek.mo_hdr mo
                ON concat(mo.bld_proj_id,'%') like ud2.udt02_name
            WHERE ud2.udt02_id=ctree.charge_cd
            AND mo.s_mo_status_cd in ('L','C') 
            AND mo.complt_dt <= SYSDATE -7
            OR mo.allow_timesheet_fl='N');

It deletes as is supposed to it just takes a really long time for the script to run even when there are no records to delete. (last time it ran almost 20 minutes).

0

There are 0 best solutions below