Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: About CBO cost in oracle10g

Re: About CBO cost in oracle10g

From: eygle <eygle_at_itpub.net>
Date: 24 May 2004 20:42:33 -0700
Message-ID: <f9bc34d.0405241942.35063c5b@posting.google.com>


Thanks Jonathan;

I do the research because another test.
I have some test about in and exists :

The first,I create a big table and a small table with index:

create table big as select * from all_objects; insert /*+ append */ into big select * from big; commit;
insert /*+ append */ into big select * from big; commit;
insert /*+ append */ into big select * from big; commit;
insert /*+ append */ into big select * from big; create index big_idx on big(object_id);

create table small as select * from all_objects where rownum < 100; create index small_idx on small(object_id);

And then I analyze all of them:

analyze table big compute statistics
for table
for all indexes
for all indexed columns
/
analyze table small compute statistics
for table
for all indexes
for all indexed columns
/

With sql_trace ,I got the following result under rbo and cbo:

With rbo,Oracle chose a NL ,and got result quickly. Oracle Chose FTS to small table,I think it's good.


select /*+ rule */ count(subobject_name)   from big
 where object_id in ( select object_id from small )

call     count       cpu    elapsed       disk      query    current  
     rows

------- ------ -------- ---------- ---------- ---------- ----------
Parse        1      0.00       0.01          0          0          0  
        0
Execute      1      0.00       0.00          0          0          0  
        0
Fetch        2      0.04       0.04          8       1696          0  
        1

------- ------ -------- ---------- ---------- ---------- ----------
total        4      0.04       0.05          8       1696          0  
        1

Misses in library cache during parse: 1
Optimizer goal: RULE
Parsing user id: 120

Rows Row Source Operation

-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=1696 r=8 w=0 time=40677 us)
   1584 TABLE ACCESS BY INDEX ROWID BIG (cr=1696 r=8 w=0 time=36437 us)

   1684 NESTED LOOPS (cr=108 r=0 w=0 time=12631 us)

     99     VIEW  (cr=4 r=0 w=0 time=1144 us)
     99      SORT UNIQUE (cr=4 r=0 w=0 time=982 us)
     99       TABLE ACCESS FULL SMALL (cr=4 r=0 w=0 time=400 us)
   1584     INDEX RANGE SCAN BIG_IDX (cr=104 r=0 w=0 time=6053
us)(object id 15290)

But with CBO:
I found,Oracle choose FTS to big table.
And got a slowly explain and much more disk & query read.

In CBO,Oracle Choose "NESTED LOOPS SEMI",I donn't know the exactly internal operation of it ,but the explain is bad,i think.


select count(subobject_name)
  from big
 where object_id in ( select object_id from small )

call     count       cpu    elapsed       disk      query    current  
     rows

------- ------ -------- ---------- ---------- ---------- ----------
Parse        1      0.00       0.00          0          0          0  
        0
Execute      1      0.00       0.00          0          0          0  
        0
Fetch        2      1.50       1.47       1038       2087          0  
        1

------- ------ -------- ---------- ---------- ---------- ----------
total        4      1.50       1.48       1038       2087          0  
        1

Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 120

Rows Row Source Operation

-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=2087 r=1038 w=0 time=1478050 us)
   1584 NESTED LOOPS SEMI (cr=2087 r=1038 w=0 time=1475992 us)  166576 TABLE ACCESS FULL BIG (cr=2085 r=1038 w=0 time=470339 us)    1584 INDEX RANGE SCAN SMALL_IDX (cr=2 r=0 w=0 time=425865 us)(object id 15292)

And then I trace it with 10053 event.
In Join Order section,Oracle try every possible join order. But when using Big table with outer table,Oracle just give a cheaper cost,and choose it.

I donn't know how Oracle got it.So I try to find out how Oracle calculate cost .

I test it in Oracle9i and Oracle10g,All do the same.

Thanks again for you help.



"Jonathan Lewis" <jonathan_at_jlcomp.demon.co.uk> wrote in message news:<c8tqla$idf$1_at_sparta.btinternet.com>...
> I've had a quick look at this.
> The numbers are different on my system, but
> the principle is the same - the cost is not the
> cost of outer + (card of outer * cost of inner)
> for the nested loop FTS.
>
> For the moment I'm just going to guess that this
> is a tweak that's been put in specifically for
> nested loop FTS - allowing for (a) the segment
> header block not being read on every pass, and
> (b) an arbitrary caching fudge factor.
>
>
> --
> Regards
>
> Jonathan Lewis
>
> http://www.jlcomp.demon.co.uk
>
> http://www.jlcomp.demon.co.uk/faq/ind_faq.html
> The Co-operative Oracle Users' FAQ
>
> http://www.jlcomp.demon.co.uk/seminar.html
> Optimising Oracle Seminar - schedule updated May 1st
>

> Received on Mon May 24 2004 - 22:42:33 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US