oracle - SELECT takes 100ms; CREATE table as select - or - INSERT into select take 15mins -


i have simple select * query where not exists clause.

select * "bman_tp3"."tt_spldr_55e63a28_59358" select_table not exists (select * "bman_tp3"."user_def_attributes" exists_table                   "select_table"."uda_name" = "exists_table"."uda_name") 

this query 100 ms execute , fetch < 2000 records.

if query nested in create table as or in insert into runs in 15 minutes.

create table bman_tp3.tt_uda_test tablespace bman_tp3_u (   select *   "bman_tp3"."tt_spldr_55e63a28_59358" select_table   not exists (select * "bman_tp3"."user_def_attributes" exists_table                     "select_table"."uda_name" = "exists_table"."uda_name") ) 

i have unique index on uda_name field of both user_def_attributes (alternate-key) , tt_spldr_55e63a28_59358 tables.

if remove where not exists takes half second.


edit :

if use

left outer join "bman_tp3"."user_def_attributes" on "select_table"."uda_name" = "user_def_attributes"."uda_name" "user_def_attributes"."uda_name" null 

instead of where not exists runs in half second.

i cannot explain why where not exists slow!


explain create table not exists : (15 mins)

enter image description here

explain create table left outer join : (500 ms)

enter image description here


explain select not exists : (100ms)

enter image description here

explain select left outer join : (100ms)

enter image description here

it seems when selecting makes same operations, when creating table different operations where not exists , left outer join

ok, found it.

it's alternate-key on uda_name table user_def_attributes.

if disable , create unique index on same field, runs in 500 millis.

anyway, i'm not sure reason of behavior.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -