Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Full Table Scan with Connect By on Oracle 9.2.0.7.0

685605Apr 20 2010 — edited Apr 20 2010
I'm having problems in a select statement with connect by and start with that it's doing full table scan in a indexed table. The start with statement does a join by PK and still does FTS.

The select statement is this:
select cta.cod_conta_contabil
from ct_conta_contabil cta
where cta.tipo_conta = 'L'
connect by prior cta.cod_conta_contabil = cta.cod_conta_pai
start with cta.cod_conta_contabil = :b1
PK and index ICT_CONTACTB2 of ct_conta_contabil table, useds in explain plan:
alter table CT_CONTA_CONTABIL add constraint PKCT_CONTACTB primary key (COD_CONTA_CONTABIL)
create index ICT_CONTACTB2 on CT_CONTA_CONTABIL (COD_CONTA_PAI)
Explain plain on Oracle 9i:
SELECT STATEMENT, GOAL = RULE               
CONNECT BY WITH FILTERING               
  TABLE ACCESS BY INDEX ROWID   FINPAC   CT_CONTA_CONTABIL         
   INDEX RANGE SCAN   FINPAC   PKCT_CONTACTB        
  NESTED LOOPS               
   BUFFER SORT               
    CONNECT BY PUMP               
   TABLE ACCESS BY INDEX ROWID   FINPAC   CT_CONTA_CONTABIL         
    INDEX RANGE SCAN   FINPAC   ICT_CONTACTB2         
  TABLE ACCESS FULL   FINPAC   CT_CONTA_CONTABIL   
Explain plan on Oracle 10g:
SELECT STATEMENT, GOAL = CHOOSE
CONNECT BY WITH FILTERING               
  TABLE ACCESS BY INDEX ROWID   FINPAC   CT_CONTA_CONTABIL
   INDEX RANGE SCAN   FINPAC   PKCT_CONTACTB
  NESTED LOOPS               
   CONNECT BY PUMP               
   TABLE ACCESS BY INDEX ROWID   FINPAC   CT_CONTA_CONTABIL
    INDEX RANGE SCAN   FINPAC   ICT_CONTACTB2
I found some topics about this subject in Metalink, but didn't find the solution. As i see, this problem wasn't solved in 9i.

Anyone knows another way that make a hierarchical select without connect by or with connect by, but without FTS?

Regards,

Fabrício Pinto

Edited by: Fabrício Pinto on 20/04/2010 16:53

Edited by: Fabrício Pinto on 20/04/2010 17:03
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2010
Added on Apr 20 2010
2 comments
1,325 views