Subject Speed Optimization required for DELETE query
Author Vishal Tiwari
 
Hi Helen.... Hi Set.....

I came back again....
 
Is there anything wrong with EXISTS predicate i used in Query no.2
Because Query no. 1 deletes certain records where as Query no.2 deletes no records.
 
Could you plz. tell me where i am making mistake for query no. 2.
will ESISTS predicate give benifit in query no. 2, means can delete any records with some modification in query no. 2.
 
Both the queries are given below.
 
regards
 
Have A Nice Day.

Vishal Tiwari...

*******************************
Query No.1:
 
Delete from Table_C C
where
C.dt_date <= '03/01/2007'
And
C.var_EmpCode not In (
select var_EmpCode from Table_A A
join Table_B B
On
A.var_EmpCode = B.var_EmpCode
And
A.var_PGCode = B.var_PGCode
And
(A.var_Status = 'I'
or
A.var_Resigned_ But_Not_Settled = 'Y') )
and Max(B.dt_AppliedDat e) <= '03/31/2007' );
 
 
Query No.2:
 
Delete from Table_C C
where
C.dt_date <= '03/01/2007'
And
not exists (
select var_EmpCode from Table_A A
join Table_B B
On
A.var_EmpCode = B.var_EmpCode
And
A.var_PGCode = B.var_PGCode
And
(A.var_Status = 'I'
or
A.var_Resigned_ But_Not_Settled = 'Y') )
and Max(B.dt_AppliedDat e) <= '03/31/2007' );



Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com

[Non-text portions of this message have been removed]