Query Help:
I have three tables which were joined on non-unique index key.
Tables:
Tab1 has 2 Million Rows.
Tab2 has 50K
Tab3 has 1K..
select distinct Tab1.col1 , Tab1.col2
from Tab1 T1
where not exists
( select '1' from Tab2 T2
where T2.col1 = T1.col1 )
and not exists
( select '1' from Tab3 T3
where T3.col1 = T1.col1 )
and T1.col1 is not null
and T1.Col2 is not null
The above query is not coming out at all and hanging.
Tab1 --> Col1 has 30K distinct values --> Has Index on Col1 -> 100K rows are Null values.
Tab2 --> No index on Col1 ( Because this is concatenated field from three derived values )
Tab3 --> Has Index on Col1.
Any Help in writing this query efficeintly helpfull.
1) I tried using NOT IN clause for Tab3
2) Tried selecting COL1 from Tab2 and Tab3 using Union ..
please help.
Thanks
Jim
I have three tables which were joined on non-unique index key.
Tables:
Tab1 has 2 Million Rows.
Tab2 has 50K
Tab3 has 1K..
select distinct Tab1.col1 , Tab1.col2
from Tab1 T1
where not exists
( select '1' from Tab2 T2
where T2.col1 = T1.col1 )
and not exists
( select '1' from Tab3 T3
where T3.col1 = T1.col1 )
and T1.col1 is not null
and T1.Col2 is not null
The above query is not coming out at all and hanging.
Tab1 --> Col1 has 30K distinct values --> Has Index on Col1 -> 100K rows are Null values.
Tab2 --> No index on Col1 ( Because this is concatenated field from three derived values )
Tab3 --> Has Index on Col1.
Any Help in writing this query efficeintly helpfull.
1) I tried using NOT IN clause for Tab3
2) Tried selecting COL1 from Tab2 and Tab3 using Union ..
please help.
Thanks
Jim