I'm experiencing very poor performance in a Oracle SQL query. The query is this:
 SELECT distinct idm3.cod
    FROM ibe_partos_m idm3, ibe_padron_prov_2010_m pad2
   WHERE     idm3.codLote = 1
         AND idm3.activo = 1
         AND ((pad2.ar = '2016' and pad2.mes='1') or (pad2.ar = '2015' and pad2.mes='7'))
         AND idm3.cod NOT IN                
           (SELECT idm2.cod
              FROM ibe_partos_m idm2,
                   ibe_padron_prov_2010_m pad
             WHERE     idm2.codLote = 1
                   AND idm2.activo = 1
                   AND ((pad.ar = '2016' and pad.mes='1') or (pad.ar = '2015' and pad.mes='7'))
                   AND pad.tiden != '2'
                   AND idm2.nombreM = pad.NOMB
                   AND idm2.apell1m = pad.APE1
                   AND idm2.apell2m = pad.APE2
                   AND (    idm2.numdocm = pad.IDEN || pad.LIDEN OR 
                                idm2.numdocm = pad.NDOCU OR 
                                idm2.numdocm = pad.LEXTR|| pad.IDEN|| pad.LIDEN OR 
                                idm2.numdocm = pad.LEXTR || '0' || pad.IDEN|| pad.LIDEN OR 
                                idm2.numdocm = pad.lextr || SUBSTR (pad.iden, 2, LENGTH (pad.iden))|| pad.liden)
                )                        
         AND idm3.PROREM = '07'
         AND idm3.nombreM = pad2.nomb
         AND idm3.apell1m = pad2.ape1
         AND idm3.apell2m = pad2.ape2
         AND (   (pad2.tiden = '1' AND pad2.liden IS NOT NULL)
              OR (    pad2.tiden = '3'
                  AND pad2.liden IS NOT NULL
                  AND pad2.lextr IS NOT NULL));
I've indexes defined in table ibe_partos_m, field codlote and field cod; and in table ibe_padron_prov_2010_m, fields ape1, ape2 and iden. All indexes are simple.
I can't understand why I'm having that poor performance...isn't the 2 indexes in ape1 and ape2 suffice for improving the join velocity?
Thank you in advance!!
Edit: what I'm trying to achieve is this:
- Let's define the records that are correct as the records selected in the inner select. 
- I'm trying to get the records that are not correct in the former sense, but still fits into some properties, that are: - idm3.codLote = 1 AND idm3.activo = 1 AND ((pad2.ar = '2016' and pad2.mes='1') or (pad2.ar = '2015' and pad2.mes='7')) AND idm3.PROREM = '07' AND idm3.nombreM = pad2.nomb AND idm3.apell1m = pad2.ape1 AND idm3.apell2m = pad2.ape2 AND ( (pad2.tiden = '1' AND pad2.liden IS NOT NULL) OR ( pad2.tiden = '3' AND pad2.liden IS NOT NULL AND pad2.lextr IS NOT NULL));
Edit2: As @Craig Young correctly suspects, I'm only interested (in both selects) in obtaining distinct cod...but is there some way to tell the DB server to stop searching for a given ibe_partos_m once a match is found in some or both selects?
 
     
     
    