question

BI DWH BALA avatar image
BI DWH BALA asked

Cost based optimizer (CBO) question?

We have CBO Cost based Optimizer in oracle which will optimize the query. Do we need to do any settings in oracle in order to enable this?

Thank you,

Regards

BI DWH BALA

oracleperformance
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KillerDBA avatar image
KillerDBA answered

According to this, if you're on 10g, the cost-based optimizer is the only optimizer:

TechRepublic

so it's "enabled" by default.

I also found this, referring to the 8i release:

Oracle-Base

which says:

Rule Based Optimizer (RBO) - This method is used if the server has no internal statistics relating to the objects referenced by the statement. This method is no longer favoured by Oracle and will be desupported in future releases. 
and
Cost Based Optimizer (CBO) - This method is used if internal statistics are present. The CBO checks several possible execution plans and selects the one with the lowest cost, where cost relates to system resources.

So, it seems that you will use CBO in earlier releases than 10g, if you gather stats.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

BI DWH BALA avatar image BI DWH BALA commented ·
This is really good feature. Once we collect statistics, oracle will take care of performance optimization. This sounds good and reduce the users responsibility in tuning part. And the links are good. Thanks for sharing with us. Thanks once again.
0 Likes 0 ·
Tariq Rahiman avatar image
Tariq Rahiman answered
  1. The optimizer mode can be set at the system-wide level, for an individual session, or for a specific SQL statement:

alter system set optimizer_mode=first_rows_10; alter session set optimizer_goal = all_rows; select /*+ first_rows(100) */ from table_nme;

  1. OPTIMIZER_MODES

    • first_rows
    • first_rows_1
    • first_rows_10
    • first_rows_100
    • first_rows_1000
    • all_rows
    • choose
    • rule

Resources

http://www.dba-oracle.com/art_otn_cbo.htm

http://www.dba-oracle.com/t_gogala_cbo_oltp2.htm

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.