Archives of the TeradataForum
Message Posted: Thu, 01 Aug 2002 @ 11:41:58 GMT
Subj: | | Incorrect Processing of NOT EXISTS? |
|
From: | | Doorey, Andrew ST |
Has anyone had any problems with NOT EXISTS not working as expected? I've just produced explains for 3 methods of achieving the same
result. In the following examples there is a NUSI on colA on big_table:
(1) select colA
from small_table
where colA not in
(select colA from big_table )
group by 1
(2) select colA
from small_table t1
where not exists
(select 1 from big_table t2 where t1.colA = t2.colA )
group by 1
(3) select colA
from small_table
where colA not in
(select t1.colA
from small_table t1
,big_table t2
where t1.colA = t2.colA
)
group by 1
I would have expected method 2 to have a similar explain to method 3. However methods 1 & 2 both read big_table into spool (which
takes over an hour), whereas method 3 just reads the index (which takes about a minute).
We've recently applied a minor upgrade and are now on V2R.04.01.01.12 release 04.01.01.36. Does anyone know if this is correct and has
anyone else had any similar problems? I don't want to write code using the 3rd method if I don't have to as it'll be harder to
maintain.
Thanks,
Andy Doorey.
|