Optimizer Mode - Rule or Choose

Is it ok to use
Alter session set optimizer_mode=RULE?
in Oracle9i and Oracle10g?
thanks.

New book on physical database design, discussing how to design indexes, range and hash partitioning, materialized views, storage layout, RAID, warehouse design and more. The book covers Oracle and several other major databases. Lots of diagrams and examples. An excellent text for people who design and administer databases.
Available on Amazon and most other book sellers.
Physical Database Design: The Database Professional's Guide to Exploiting Indexes, Views, Storage, and More
by Sam S. Lightstone, Toby J. Teorey, Tom Nadeau
Paperback, 448 pages, publication date: MAR-2007
ISBN-13: 978-0-12-369389-1
ISBN-10: 0-12-369389-6
Series: The Morgan Kaufmann Series in Data Management Systems
Link on Amazon:
http://www.amazon.com/Physical-Database-Design-professionals-exploiting/dp/0123693896
Link on the publisher's web site:
http://www.elsevier.com/wps/find/bookdescription.cws_home/710637/description#description
Comments on the book can be sent to: [email protected]

Similar Messages

  • Oracle Optimizer Mode Choose / Rule

    Hello,
    we have a strange behavior with Oracle 9.2
    We have a application doing
    SELECT to_char(COLUMNNAME)
    FROM
    VIEW WHERE ROWNUM = 1
    This statement needs 75 seconds executed on the server within the application.
    call count cpu elapsed disk query current rows
    Parse 68 0.01 0.02 1 108 0 0
    Execute 136 0.14 0.14 0 0 0 0
    Fetch 68 68.74 75.64 119587 181628 2 68
    total 272 68.89 75.81 119588 181736 2 68
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 25
    Rows Row Source Operation
    1 COUNT STOPKEY
    1 HASH JOIN
    524213 TABLE ACCESS FULL TABLEA
    6 INDEX FAST FULL SCAN INDEX (object id 7026)
    Optimizer mode is CHOOSE and we have generated Statistics.
    When we switch to RULE the SQL will perform within millseconds
    call count cpu elapsed disk query current rows
    Parse 68 0.01 0.00 0 2 0 0
    Execute 68 0.00 0.00 0 0 0 0
    Fetch 68 0.01 0.05 68 476 0 68
    total 204 0.02 0.05 68 478 0 68
    Misses in library cache during parse: 1
    Optimizer goal: RULE
    Parsing user id: 25
    Rows Row Source Operation
    1 COUNT STOPKEY
    1 NESTED LOOPS
    1 TABLE ACCESS FULL TABLEA
    1 INDEX UNIQUE SCAN INDEX (object id 7026)
    Even when executing this statement within SQLPLUS on the server it takes 1 second (even too long but not 70 seconds).
    Has anybody a hint where to look ?? I´m really confused.
    Kind Regards,
    Klaus

    Optimizer mode choose with statistics effectively means ALL_ROWS. So I suspect that this probably is the reason why Oracle uses full scans and hash joins. On the other hand rownum = 1 should give the optimizer info that you only need 1 row back. So probably try with either optimizer_mode = first_rows_1 or hint first_rows(1) and see what happens.
    Gints Plivna
    http://www.gplivna.eu

  • Change optimizer_mode from rule to choose ?

    Hi All
    Could we change optimizer mode from rule to choose by restarting the instance
    thanks
    kedar

    Yes. It is needed if your are using a text intialization file and want the change to be permanent.
    See http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96536/ch13.htm#1013938
    If you are using a spfile, you don't need to restart the instance, just run:
    ALTER SYSTEM SET optimizer_mode=choose;
    The parameter will be changed in a permanant way.
    See: http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96536/ch1140.htm#1021526
    and
    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96536/ch13.htm#1013935
    Message was edited by:
    Pierre Forstmann
    Message was edited by:
    Pierre Forstmann

  • Set optimizer mode for someone else possible?

    I know that I can use the sys.dbms_system package to set tracing on for another session but cannot figure how to change their optimizer mode - if it's possible at all.
    I have tried this -
    exec sys.dbms_system.set_bool_param_in_session(20,176,'optimizer_mode=choose',TRUE);
    PL/SQL procedure successfully completed.
    SQL> show parameter opt
    NAME TYPE VALUE
    object_cache_optimal_size integer 102400
    optimizer_features_enable string 8.1.7
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_max_permutations integer 80000
    optimizer_mode string RULE
    optimizer_percent_parallel integer 0
    Tried the 'set_int_param_in_session' but 'choose' is not an integer.
    Thanks in advance for any help.

    Hi,
    in design center, select "configure" in the context menu of a mapping. Under table operators, select a table and set the extraction hint.
    Regards,
    Carsten.

  • What is the default optimization(CBO/RBO) method choose in Oracle 9i DB?

    What is the default optimization(CBO/RBO) method choose in Oracle 9i DB?
    Note : If we set the OPTIMIZER MODE as CHOOSE

    1) So you mean to say that, for all the tables if we are maintaining statistics, by default it will go for CBO, else RBO right?Yes, unless you dont specify a hint RULE to your queries. At least one table contains statsitics in a two or more table join select statement, oracle uses CBO and calculates statistics using their no. of blocks and other stuff, some internal calculations.
    Also, becarefull, old statistics can lead optimizer to choose very pool plan that impact query performance.
    2) If we are using CBO, then what will be the order of execution in the where clause, Is it from top to bottom, or reverse?If its a single table with where clause, then, oracle choose either full table scan, or index range scan depends upon the column mentioned in the where clause and availabl indexes.
    If query contains multiple tables, then, oracle has to decide between join methods, such as, nested loop, hash join, sort merge join and etc.
    3) And also If we are using RBO, then what will be the order of execution in the where clause, Is it from top to bottom, or reverse?
    RBO uses its internal calculation to produce the execution plan, more probably gives preference to indexes if a column has an index which appears in the where cluase.
    Jaffar

  • Optimizer mode in oracle 10g

    what is the difference between setting optimizer mode in oracle 10g
    optimizer_mode=choose
    optimizer_mode=all_rows

    user446367 wrote:
    what i have to set for the below parameters . any idea ?
    optimizer_index_caching
    optimizer_index_cost_adjIn general you would leave them set at the default value in 10g (and probably, in most earlier versions, for most cases as well). Even if you were to change them, asking for specific values on an internet forum is rather asking for trouble, it's not dissimilar to asking "what should I set for the parameter processes?" A reasonable value will be application dependent.
    The first parameter reduces the cost of some types of indexed access by assuming that only the specified percentage of index i/o actually results in a physical I/O and therefore only that percentage of the io cost is taken into account. By contrast all tablescan access and the other types of indexed access are assumed to be uncached and therefore need costing.
    The second parameter just arbitrarily scales indexed access path costings.
    You could argue, and some have, that you could calculate a cache hit ratio for index blocks in much the same way as you can calculate a cache hit ratio generally and then set the first parameter to this value. The standout problems with this approach are
    1) It applies to all matching statements and objects not just your problem ones.
    2) It doesn't necessarily even apply to your problem statements.
    3) It doesn't have anything to do with query duration per se, just efficiency of one particular access path.
    4) People tend to choose to round costs down and make the likelihood of two plans getting the same cost and being chosen on a tiebreaker basis higher.
    The second parameter just asks you how much you like the idea of indexes generally. If you are going to change it pick a family members age or something - it'll make you smile every time you see it.
    Niall Litchfield
    http://www.orawin.info/

  • About optimizer mode

    Hi,
    How to change the optimizer mode from ALL_ROWS
    Thanks

    Whether we do not know the OP's Oracle version, we can assume it is not 8i or 9i. Do you realize the link you provided is very old. Still speaking about RULE optimizer, "analyze table" command (both becoming obsolete then depracted) without telling anything about more modern database such as 10g+. Moreover there're some rule of thumbs which can mislead query tuning.
    Much better to refer to the Oracle document that Pierre linked to in first place.
    And why not ask to the OP, why he/she wants to modify the optimizer from ALL_ROWS to what value with what expected results, based on what analyzes...
    Nicolas.

  • Optimizer mode confusion

    Hello experts,
    When we set optimizer mode to first_rows_100 or first_rows etc. The fetch rows doesn't change. I am trying to understand the differences between first_rows and all_rows. It gives preference to index scan against full table scan, even the index scan is no good. And also prefers nested loop over hash join. HOWEVER, except all these, please correct me if I am wrong, I do understand that first_nows_100 only fetch 100 rows regardless default fecth row, am I wrong? What do you think about the following example in terms of CONSISTENT GETS????
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> alter system flush shared_pool;
    Sistem dei■tirildi.
    SQL> set autotrace traceonly
    SQL> select * from my_test where id < 181000;
    31000 sat²rlar² seildi.
    Y³r³tme Plan²
    Plan hash value: 1615681525
    | Id  | Operation         | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |         | 31001 |   605K|    53   (2)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| MY_TEST | 31001 |   605K|    53   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ID"<181000)
    ¦statistikler
            454  recursive calls
              0  db block gets
           2323  consistent gets
             93  physical reads
            116  redo size
         843244  bytes sent via SQL*Net to client
          23245  bytes received via SQL*Net from client
           2068  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
          31000  rows processed
    SQL> select * from my_test where id < 181000;
    31000 sat²rlar² seildi.
    Y³r³tme Plan²
    Plan hash value: 1615681525
    | Id  | Operation         | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |         | 31001 |   605K|    53   (2)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| MY_TEST | 31001 |   605K|    53   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ID"<181000)
    ¦statistikler
              0  recursive calls
              0  db block gets
           2235  consistent gets
              0  physical reads
              0  redo size
         843244  bytes sent via SQL*Net to client
          23245  bytes received via SQL*Net from client
           2068  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          31000  rows processed
    SQL> alter session set optimizer_mode = FIRST_ROWS_100;
    Oturum dei■tirildi.
    SQL> select * from my_test where id < 181000;
    31000 sat²rlar² seildi.
    Y³r³tme Plan²
    Plan hash value: 509756919
    | Id  | Operation                   | Name         | Rows  | Bytes | Cost (%CPU)
    | Time     |
    |   0 | SELECT STATEMENT            |              |   100 |  2000 |     4   (0)
    | 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| MY_TEST      |   100 |  2000 |     4   (0)
    | 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | SYS_C0011105 |       |       |     2   (0)
    | 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("ID"<181000)
    ¦statistikler
              1  recursive calls
              0  db block gets
           4402  consistent gets
              0  physical reads
              0  redo size
        1159430  bytes sent via SQL*Net to client
          23245  bytes received via SQL*Net from client
           2068  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          31000  rows processed
    Thanks in adnvance.

    the first_rows(n) hint is only about costing and instructs the optimizer to find a plan that returns the first n rows as fast as possible - though this approach may increase the total execution time for the query. This could be useful for applications that need only the top results most the time. Consider the following example:
    drop table t;
    create table t (
        col1 not null
      , col2
    as
    select mod(rownum, 100) col1
         , lpad('*', 50, '*') col2
      from dual
    connect by level <= 100000;
    exec dbms_stats.gather_table_stats(user, 'T')
    create index t_idx on t(col1);
    explain plan for
    select *
      from t
    where col1 = 1
    order by col1;
    select * from table(dbms_xplan.display);
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |  1000 | 54000 |   423   (0)| 00:00:03 |
    |*  1 |  TABLE ACCESS FULL| T    |  1000 | 54000 |   423   (0)| 00:00:03 |
    Predicate Information (identified by operation id):
       1 - filter("COL1"=1)
    explain plan for
    select /*+ first_rows(10) */
      from t
    where col1 = 1
    order by col1;
    select * from table(dbms_xplan.display);
    | Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |       |    10 |   540 |    10   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T     |    10 |   540 |    10   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | T_IDX |       |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("COL1"=1)
    Obiously the hint changes the costing massively - and for the given query the top 10 results could indeed be returned faster by the index scan (though the difference would be small for this small example).
    The details of the costing are not that simple and they are described in Randolf Geist's presentation http://www.sqltools-plusplus.org:7676/media/FIRST_ROWS_n%20presentation%20UKOUG%202009.pdf (titled: Everything you wanted to know about first_rows_n but were afraid to ask).

  • EXPORT 와 OPTIMIZER MODE

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-08
    EXPORT 와 OPTIMIZER MODE 관계
    =============================
    PURPOSE
    다음은 EXPORT와 OPTIMIZER MODE의 관계에 대해 알아본다.
    Explanation
    EXPORT시 5 분 걸리던 작업이 init.ora 에 optimizer_mode=first_rows 로
    하면 20 시간이 걸리는 현상이 발생된다.
    이는 BUG# 391656 이었으며 optimizer_mode 를 first_rows 로 설정후
    export시 rows=n 으로 주어도 export time이 굉장히 오래 걸린다는 내용으로
    event 10046을 setting후 각 statement path 를 check 해보니 optimezer 가
    CDEF$ 와 COL$ table 을 fulle scan 하는 것으로 나타 났다.
    이들 table 은 EXU7COLU view 에 의해 실행되고 , 만일 DB 에 constraint가
    많고 table comment 가 많다면 많은 시간이 걸려서 이러한 결과가 나타난다.
    이 경우는 CDEF$ 와 COL$를 analyze 한다 하더라도 별 도움이 안되고
    optimizer_mode=first_rows 를 사용하지 말아야 한다는 것이다.
    V7.1.6 에서의 임시 workaround 로
    CREATE OR REPLACE view exu7grnu AS
    SELECT * from exu7grn WHERE grantorid = UID AND creatorid+0 = UID
    CREATE OR REPLACE view exu7cgru AS
    SELECT * from exu7cgr WHERE grantorid = UID AND creatorid+0 = UID
    CREATE OR REPLACE view exu7spsu(obj#, line, source) AS
    SELECT s.obj#, s.line, s.source
    FROM sys.source$ s, sys.obj$ o
    WHERE s.obj# = o.obj# and o.owner#+0 = UID
    처럼 view 를 create 하는 방법이 있다.
    Reference Ducuments
    --------------------

    Jim,
    Export does run in a background process. There are actually at least 3 processes running.
    1. You have the client, which is where you run your expdp/impdp command.
    2. You have the MCP processes which is a Data Pump process
    3. You have a WORKER processes (or more if you use parallel) that are Data Pump processes.
    I always use LINUX, but I think it works the same for Windows. Once you have the job running, you can type a CTL-C and you will get to an IMPDP> or EXPDP> prompt. This allows you to do other commands. One is to exit the client process. You can also stop the job or kill the job. Try it and type HELP at one of those prompts.
    At this same prompt, you can type STATUS will will give you some idea on what is being worked on.
    Some of the reasons you would want to attach to a job is
    1. You previously exited and want to reattach to change something.
    2. You left it running while you were in the office and now you are home and want to see the status. (you can have multiple clients attached to the same data pump job.
    3. Your job stopped for some reason (power outage, failure, etc.) and you want to restart it.
    Hope this helps.
    Dean

  • Set optimizer mode for mapping

    How can i set the optimizer mode(for example, "all_rows") explicitly for a mapping?
    ~Prabha

    Hi,
    in design center, select "configure" in the context menu of a mapping. Under table operators, select a table and set the extraction hint.
    Regards,
    Carsten.

  • How to get the Optimizer Mode

    How can I get the optimizer mode from the database? I've tried by querying the table V$PARAMETER but I get "table or view does not exist" even if verifying in ALL_OBJECTS I see that it's indicated as Owner PUBLIC. Could you help me? Thanks

    SQL> connect hr/hr
    Connected.
    SQL> SHOW PARAMETER OPTIMIZER_MODE
    ORA-00942: table or view does not exist
    SQL> connect sys/girish as sysdba
    Connected.
    SQL> SHOW PARAMETER OPTIMIZER_MODE
    NAME                                 TYPE        VALUE
    optimizer_mode                       string      ALL_ROWSGirish Sharma

  • Optimizer Mode

    The database wizards are kicking my tables into cost based
    mode. We run our queries in rule mode. When I use the DB
    Servlet Wizard or the Info Bus Data Form Wizard, any tables
    I use get "analyzed" which kicks any queries into cost based
    mode because our DB is set for "choose".
    Any ideas how to keep it from analyzing my tables?
    thanks,
    bl
    null

    Probably not. Is it just the plan order that's changed or has the cost changed too? More importantly does either version of the query take significantly longer to execute?
    Incidentally, OPTIMIZER=CHOOSE does not mean the database always uses the CBO. It means it chooses. If none of the tables in the statement has statistics it uses the RBO. If one of the tables in the statement has statistics it uses the CBO. Note that if there are tables that don't have statistics, the database estimates (ie guesses) them, which can lead to some wildly inaccurate plans. This is why we should analyze whole schemas and not individual tables.
    If you want to always use the CBO you should chnage the init.ora parameter to OPTIMIZER=COST
    rgds, APC

  • What should be optimizer mode

    Oracle 10g Rl- 2 (RAC)
    OS- HP-UX 11i
    Optimizer_mode parameter is all_rows in my database. It is OLTP enviornment.
    What should be the the optimizer in this condition?

    pls go through this link.
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams145.htm

  • How to change the optimizer to rule?

    Hi,
    I am just a oracle developer, i recently downloaded and installed oracle 10g in my laptop and i want to use the explain plan to check my queries. My comp uses rule based. Appreciate if any body help me to change to rule base.
    thanks

    Hi,
    If Oracle has the statistics of the table then it will go for COST based otherwise it will go for RULE based. So if you want COST based then first gather statistics of the tables and run explain plan.
    For more details please see the below link:
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76992/optimops.htm#38183
    Regards
    Avinash

  • Quality Inspection - Sampling procedure, Sampling scheme & Dyn. Mod. rule

    Hi Experts,
    I am impementing QM process to our group of company. Can you please help me?
    How to link Sampling procedure, Sampling scheme & Dynamic modification rule??
    It is very helpful for me, if you give a brief on this at the earliest.
    reg,
    RPV

    Dear Velu,
    Please go through the following link..........
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/44/fb8928a95e11d2839e0000e829fdb3/frameset.htm
    Regards,
    VB

Maybe you are looking for

  • LT12 TO confirmation error for multiple line items

    Hi Experts, We recently upgraded to ECC 6 DIMP EP6. We are not able to confirm TO with multiple line items. It is failing with an error message VL 198 that 0 quantity of material is available. We are able to confirm TO line items one by one. This TO

  • Screen Issues with MacBook Pro (Static Lines)

    Hey guys.  I aam having problems with my Screen/Display on my Macbook Pro.  Static lines appear aprox 1/3 of the way in from the right side.  The lines run horizontally about 1 inch in length and running vertically all the way down the display. A scr

  • Windows 7 64 bit hangs

    Windows 7 64 bit hangs when I try to print PDF.  What to do?   Get splwow64.exe is not available. Problem Event Name:                        AppHangXProcB1 Application Name:                             EXCEL.EXE Waiting on Application Name:         s

  • No possibility to activate iMessages with my iPhone 4

    Hi everibody ! I have an iPhone 4 ! I can't activate iMessages on it !! When I'm trying I get a message that told me to verify my connection but I'm connected in 3G and Wi-fi. I arrived to activate once but only with my email address. When I go on th

  • How do I sync my files from TC back onto my new computer

    Im trying to sync my files from my TC back onto my new computer, but I forgot the password and I don't understand how to reset the TC password..