Okay - I've already said I'm not very good at this coding lark....
explain plan for
select *
from affected_cat_cust
where (hurn,purn,cat_id) in
(select hurn,purn,cat_id
from
(select hurn,purn,cat_id,count(*)
from affected_cat_cust
group by hurn,purn,cat_id
having count(*) = 1
)
)
and (hurn,purn,cat_id) not in(select hurn,purn,cat_id from affected_catalogue_customer)
DaPi - I knew you were out there
How do I code the NOT Exists ??
I'll have another go, whilst I wait for your wisdom........
and (hurn,purn,cat_id) not exists (select hurn,purn,cat_id from affected_catalogue_customer)
*
ERROR at line 13:
ORA-00920: invalid relational operator
select *
from affected_cat_cust a1
.
.
.
.
and not exists
(select * from affected_catalogue_customer c
where c.hurn = a1.hurn
and c.purn = a1.purn
and c.cat_id = a1.cat_id)
You do have analyzed indexes on hurn, purn and /or cat_id ? (best would be one index on all three). You can do the same kind of thing for the IN as well - but there must be a better way . .. haven't seen it yet . . .
You're still doing FTS - is that inevitable? The NOT logic (as we have discussed recently) might be able to use a FIS instead . . .
The IN becoming EXISTS might be more effective: I wondered about recoding the first bit
Code:
select *
from affected_cat_cust a1
where exists
(select a2.hurn,a2.purn,a2.cat_id,count(*)
from affected_cat_cust a2
where a2.hurn = a1.hurn
and a2.purn = a1.purn
and a2.cat_id = a1.cat_id
group by a2.hurn,a2.purn,a2.cat_id
having count(*) = 1)
Bookmarks