About 10g optimizer

Hi All,
     I am wondering is any one out there has the same problem with me. I have one same schema on both 9i and 10g. The sql statement runs fine with 9i instance but not with 10g. Especially for those sql statement that has sub query in where clause. What I found out from 10g explain plan is that optimizer create a view for this sub query and it is the most killing part. Any suggestion or comments are welcome.

Hi,
there are three points you should try:
1.) Did you gather system statistics? 9i does not use them if there are not present, but 10g uses default values. But gathering system stats does not invalidate the plan in the shared pool. You will have to execute
alter system flush shared_poolor simply do some DDL to one of the objects used in your table. If a table is eg. defined with noparallel simply execute
alter table xy noparallelThis will not change the table but every statement using this table will be hard parsed again.
Now gather system statistics using:
begin
dbms_stats.gather_system_stats('start');
end;You should do this when you db is under normal workload. After a couple of time(hours) stop it:
dbms_stats.gather_system_stats('stop');2. Are you able to rewrite the sqls using subquery factoring? Does the plan change?
3. Try changing the statistics using the dbms_stats.set_table_stats and dbms_stats.set_column_stats procedure. Start with very low or high values.
Dim

Similar Messages

  • My iphone has recently loss about 10G of memmory. I check through settings/general/usage, all apps I had add up to less than 2G. I used to be able to take around 2hrs of video and now I can't take any. Can anyone help? Thanks

    My iphone has recently loss about 10G of memmory. I check through settings/general/usage, all apps I had add up to less than 2G. I used to be able to take around 2hrs of video as I like to record down whatever happening in front of my car when I'm driving. I delete the videos everyday ifn nothing special. It seems that lately when I deleted the videos, they're not removed from the phone's memmory.
    I check form setting/general/usage : all my apps add up to less than 2G. In itune, it shows all memmary is under the catagory "other". Is there any way I can access this "other" memmory to see what's in it and delete the things I don't want to regain the loss memmory?
    Thanks

    You could always try restoring, although maybe someone else on here has a better idea.
    Hopefully by posting this, it will bump up and someone with more iPhone troubleshooting experience might chime in.
    As for the videos - interesting! Do you have the iPhone on one of those window holders, or do you hold it in your hand since that might ironically distract you, unless you've gotten very good at it!

  • 10g Optimizer strange behavour

    I think the Optimizer has a problem in 10g. (or in my installation)
    Consider the following query:
    Select field1 from table where keyfield = 'ABC' (this value only occurs 10 times)
    This table has 30.000 records. If I put an index on keyfield the query tasks 5 sec. If I remove the index the query takes 1 sec. This is not logical.
    This problem only occurs on 10g, the same query takes <1 sec on Oracle 8 or Oracle 9.
    I think the Optimizer is having a problem analyzing the index. The analyzing step i think takes a lot of time (maybe 4 sec). Is this possible?
    I already removed and added the index, created statistics, also set the optimizing mode to choose; always the same results.
    Does anyone has a clue about this problem?

    According to what you described you have an index on a column with around 10/30,000 values. When the index is in place the query takes 5 seconds; without the index the query takes 1 second. Sounds like a problem to me.
    There are a few more things I would check:
    Are you using histograms? They're designed for mixed-cardinality data to allow the CBO to dynamically decide when an index will help or not based on data values. I have seldom seen them used, but they can have an effect on queries when the histogram column value is hard-coded in the WHERE clause (bind variables don't work because histograms are considered before the bind variable value is examined by the optimizer).
    Are you analyzing both the table and the index(es)? Are you using DBMS_STATS, which is supposed to be better than the ANALYZE command (I'm personally dubious for no good reason, but our DBA group swears by DBMS_STATS)?
    There is a recognized problem with 10g called "bind variable peeking". the situation is that you run the same query twice with different sets of bind variables. The query is optimized for the first execution, but the values of the second execution are such that the query runs (with the first's plan) inefficently. This can be turned off with an undocumented intialization paramter.
    I agree that the execution plans might be helpful to figure out what is going on.

  • Pl/sql boolean expression short circuit behavior and the 10g optimizer

    Oracle documents that a PL/SQL IF condition such as
    IF p OR q
    will always short circuit if p is TRUE. The documents confirm that this is also true for CASE and for COALESCE and DECODE (although DECODE is not available in PL/SQL).
    Charles Wetherell, in his paper "Freedom, Order and PL/SQL Optimization," (available on OTN) says that "For most operators, operands may be evaluated in any order. There are some operators (OR, AND, IN, CASE, and so on) which enforce some order of evaluation on their operands."
    My questions:
    (1) In his list of "operators that enforce some order of evaluation," what does "and so on" include?
    (2) Is short circuit evaluation ALWAYS used with Boolean expressions in PL/SQL, even when they the expression is outside one of these statements? For example:
    boolvariable := p OR q;
    Or:
    CALL foo(p or q);

    This is a very interesting paper. To attempt to answer your questions:-
    1) I suppose BETWEEN would be included in the "and so on" list.
    2) I've tried to come up with a reasonably simple means of investigating this below. What I'm attempting to do it to run a series of evaluations and record everything that is evaluated. To do this, I have a simple package (PKG) that has two functions (F1 and F2), both returning a constant (0 and 1, respectively). These functions are "naughty" in that they write the fact they have been called to a table (T). First the simple code.
    SQL> CREATE TABLE t( c1 VARCHAR2(30), c2 VARCHAR2(30) );
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg AS
      2     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER;
      3     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER;
      4  END pkg;
      5  /
    Package created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY pkg AS
      2 
      3     PROCEDURE ins( p1 IN VARCHAR2, p2 IN VARCHAR2 ) IS
      4        PRAGMA autonomous_transaction;
      5     BEGIN
      6        INSERT INTO t( c1, c2 ) VALUES( p1, p2 );
      7        COMMIT;
      8     END ins;
      9 
    10     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER IS
    11     BEGIN
    12        ins( p, 'F1' );
    13        RETURN 0;
    14     END f1;
    15 
    16     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER IS
    17     BEGIN
    18        ins( p, 'F2' );
    19        RETURN 1;
    20     END f2;
    21 
    22  END pkg;
    23  /
    Package body created.Now to demonstrate how CASE and COALESCE short-circuits further evaluations whereas NVL doesn't, we can run a simple SQL statement and look at what we recorded in T after.
    SQL> SELECT SUM(
      2           CASE
      3              WHEN pkg.f1('CASE') = 0
      4              OR   pkg.f2('CASE') = 1
      5              THEN 0
      6              ELSE 1
      7           END
      8           ) AS just_a_number_1
      9  ,      SUM(
    10           NVL( pkg.f1('NVL'), pkg.f2('NVL') )
    11           ) AS just_a_number_2
    12  ,      SUM(
    13           COALESCE(
    14             pkg.f1('COALESCE'),
    15             pkg.f2('COALESCE'))
    16           ) AS just_a_number_3
    17  FROM    user_objects;
    JUST_A_NUMBER_1 JUST_A_NUMBER_2 JUST_A_NUMBER_3
                  0               0               0
    SQL>
    SQL> SELECT c1, c2, count(*)
      2  FROM   t
      3  GROUP  BY
      4         c1, c2;
    C1                             C2                               COUNT(*)
    NVL                            F1                                     41
    NVL                            F2                                     41
    CASE                           F1                                     41
    COALESCE                       F1                                     41We can see that NVL executes both functions even though the first parameter (F1) is never NULL. To see what happens in PL/SQL, I set up the following procedure. In 100 iterations of a loop, this will test both of your queries ( 1) IF ..OR.. and 2) bool := (... OR ...) ).
    SQL> CREATE OR REPLACE PROCEDURE bool_order ( rc OUT SYS_REFCURSOR ) AS
      2 
      3     PROCEDURE take_a_bool( b IN BOOLEAN ) IS
      4     BEGIN
      5        NULL;
      6     END take_a_bool;
      7 
      8  BEGIN
      9 
    10     FOR i IN 1 .. 100 LOOP
    11 
    12        IF pkg.f1('ANON_LOOP') = 0
    13        OR pkg.f2('ANON_LOOP') = 1
    14        THEN
    15           take_a_bool(
    16              pkg.f1('TAKE_A_BOOL') = 0 OR pkg.f2('TAKE_A_BOOL') = 1
    17              );
    18        END IF;
    19 
    20     END LOOP;
    21 
    22     OPEN rc FOR SELECT c1, c2, COUNT(*) AS c3
    23                 FROM   t
    24                 GROUP  BY
    25                        c1, c2;
    26 
    27  END bool_order;
    28  /
    Procedure created.Now to test it...
    SQL> TRUNCATE TABLE t;
    Table truncated.
    SQL>
    SQL> var rc refcursor;
    SQL> set autoprint on
    SQL>
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    100
    TAKE_A_BOOL                    F1                                    100
    SQL> ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0;
    Session altered.
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    200
    TAKE_A_BOOL                    F1                                    200The above shows that the short-circuiting occurs as documented, under the maximum and minimum optimisation levels ( 10g-specific ). The F2 function is never called. What we have NOT seen, however, is PL/SQL exploiting the freedom to re-order these expressions, presumably because on such a simple example, there is no clear benefit to doing so. And I can verify that switching the order of the calls to F1 and F2 around yields the results in favour of F2 as expected.
    Regards
    Adrian

  • About 10g DB

    Dear all,
    I set up 10g DB in my XP windows and want to know how to manually start my DB after I've set Oracle NT service startup type to 'Manual' and deselected 'Startup instance when service is started' within 'Oracle instance startup/shutdown options' by 'Oracle administration assistant for windows'. Thks.
    Rgds,
    Edward Chan
    s

    Have you tried opening the Windows Service dialog, right-clicking on the database service and selecting Start? What about from the command line:
    c:\%ORACLE_HOME%\bin\sqlplus
    connect / as sysdba
    startup
    Alison

  • Suggestions about query optimization

    Hello,
    i have the following query i would like to write in the other way or add indexes/hints/pin in memory if it's possible so it could be better optimiized.
    Query is :
    SQL> explain plan for
      2  with a as
      3  (select * from
      4  (select msisdn,valid_from
      5  from prepaid_options_option
      6  where active =1 and option_id in (1,2) )a )
      7  select count(*) from [email protected], a
      8  where transaccessflag=6
      9  and cgpacallingparty=a.msisdn
    10  and optionid IN (16,17,18)
    11  and timestamp > a.valid_from
    12  and callcharge=0
    13  and internalcause='254';
    Explained.
    SQL> r
      1* select * from table(dbms_xplan.display)
    PLAN_TABLE_OUTPUT
    | Id  | Operation            |  Name                   | Rows  | Bytes | Cost  | Inst   |IN-OUT|
    |   0 | SELECT STATEMENT     |                         |     1 |   148 |   529K|        |      |
    |   1 |  SORT AGGREGATE      |                         |     1 |   148 |       |        |      |
    |*  2 |   HASH JOIN          |                         |     1 |   148 |   529K|        |      |
    |   3 |    REMOTE            |                         |    82 |  9922 |   529K| WENT   | R->S |
    |*  4 |    TABLE ACCESS FULL | PREPAID_OPTIONS_OPTION  |  4506 |   118K|    10 |        |      |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - access("CALL_RECORD"."CGPACALLINGPARTY"="PREPAID_OPTIONS_OPTION"."MSISDN")
           filter("CALL_RECORD"."TIMESTAMP">"PREPAID_OPTIONS_OPTION"."VALID_FROM")
       4 - filter("PREPAID_OPTIONS_OPTION"."ACTIVE"=1 AND ("PREPAID_OPTIONS_OPTION"."OPTION_ID"=1
                  OR "PREPAID_OPTIONS_OPTION"."OPTION_ID"=2))
    Note: cpu costing is off
    20 rows selected.
    SQL> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for HPUX: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    SQL> select * from [email protected];
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for HPUX: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - ProductionI think that the main problem could be in the remote partitioned table that is quite big .
    SQL> SELECT SUM (BYTES) / 1024 / 1024 / 1024 GB
      2    FROM [email protected]
      3  WHERE segment_name = 'CALL_RECORD';
            GB
    181.453125
    SQL> select num_rows,last_analyzed
      2   from [email protected]
      3   where table_name='CALL_RECORD';
      NUM_ROWS LAST_ANA
    928646610 12.03.09Can some suggestion about making changes in this query/objects be given based on this informations ?
    Thank you very much.

    Thans for the reply Urs,
    by changing that query as you suggested, i got different plan, although i can't fully understand if it means that it's better in the mean of faster execution time because i can't(yet) run those queries to see.
    new plan is :
    SQL> explain plan for
      2  with a as 
      3  (select msisdn,valid_from
      4  from prepaid_options_option
      5  where active =1 and option_id in (1,2) )
      6  select /*+ driving_site(c) */count(*) from [email protected] c,a
      7  where transaccessflag=6
      8  and cgpacallingparty=a.msisdn
      9  and optionid IN (16,17,18)
    10  and timestamp > a.valid_from
    11  and callcharge=0
    12  and internalcause='254';
    Explained.
    SQL>
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation              |  Name        | Rows  | Bytes | Cost  | Pstart| Pstop | Inst   |IN-OUT|
    |   0 | SELECT STATEMENT REMOTE|              |     1 |    78 |   529K|       |       |        |
    |   1 |  SORT AGGREGATE        |              |     1 |    78 |       |       |       |        |
    |   2 |   NESTED LOOPS         |              |     1 |    78 |   529K|       |       |        |
    |   3 |    PARTITION RANGE ALL |              |       |       |       |     1 |   128 |        |
    |*  4 |     TABLE ACCESS FULL  | CALL_RECORD  |     1 |    42 |   529K|     1 |   128 | WENT   |
    |   5 |    REMOTE              |              |     1 |    36 |    10 |       |       | !      |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       4 - filter("A2"."TRANSACCESSFLAG"=6 AND (TO_NUMBER("A2"."OPTIONID")=16 OR
                  TO_NUMBER("A2"."OPTIONID")=17 OR TO_NUMBER("A2"."OPTIONID")=18) AND "A2"."CALLCHARGE"=0 AND
                  "A2"."INTERNALCAUSE"=254)
    Note: fully remote operation, cpu costing is offas we can see the cost remained the same but there are some new columns as pstart and pstop.
    what do they mean?
    I think that it would be good to make statistics on that table , do you guys agree ?
    Also shoud i consider parallel hint option for that query ?

  • Differences in 9i and 10g optimizer

    Hi,
    If I am migrating from 9i to 10g (10.2), what are the main changes between the optimizers of these 2 versions?
    Where can I find these things in manuals?
    Amy experiances?
    Please share.
    Thanks

    I'm not sure the specifics you are looking for are mentioned in the manuals. Check the 10g New Features manual and check for positings as you are doing.
    One issue we are seeing in 10g is a phenemenon called "bind peeking". This happens when SQL is using bind variables and generates a plan to execute the query. Later the same query text is executed with different values but isn't as efficeint a plan for those values (usually due to index use; sometimes the same situation that histograms are created for) and query performance is not good the second time. There is an undocumented intitalization parameter you can find on metalink (possibly here in OTN) that can turn bind peeking off.

  • Question to Oracle about 10g RAC

    Hi:
    Does Oracle had installed 10gRAC on Redhat3.0AS either using ocfs or raw successful before the software got released?

    It is indeed successful. We've installed 10g RAC with ocfs/ASM on different storage devices such as SAN's and SCSI disk arrays .

  • About 10g reports

    Hi,
    As we did in ealier version 6i we can save the report output in text csv format.
    Same thing can we done in 10g reports?
    Thanks a lot

    Yes via DELIMITED or DELIMITEDDATA desformats, except you have a new format called SPREADSHEET which maintains more formatting for excel.

  • What's good about 10g?

    What is your favourite/ the best feature(s) new to Oracle 10g?
    I heard the 'g' stands for Grid. Has anyone taken advantage of the grid features?

    This may help;
    http://www.oracle.com/technology/pub/articles/10gdba/index.html
    In release 2 you gotta love DBMS_UTILITY.FORMAT_ERROR_BACKTRACE and DML Error Logging if you're a developer.

  • Owb 10g Optimize Merge Radio Button

    Having trouble finding documentation on what the "Optimize Merge" radio button does when configuring a mapping and setting up the tables. I am trying to optimize some slow code using an update/insert merge.

    Hi
    Without this switched on the select list for the inserts and updates will be the same, this select statement will include all transformations/expressions before the table operator regardless if they are only done for the update or insert. You could get redundant transformations being performed. So with the optimize merge switched on the code generator will analyze your graph and if possible push any transformation applicable only for insert or update to the appropriate part of the merge statement.
    For diagnosing performance the explain plan and stats packages of the database have been incorporated into mapping which may help you diagnose issues here too.
    Cheers
    David

  • To learn more about 10g Express

    Should I read the manuals for 10 g standard edition ?
    I read the documents for 10g express, but its not enough.
    There are manuals missing.
    Where do i get all the necessary books o manuals ?

    The XE manuals reference the Oracle Database 10g Release 2 manuals, which is a significantly larger manual set. The idea is that you read the XE manuals, and for further clarification (if necessary), follow the links that will take you to related topics in the larger manual set. If you do want to just read the Oracle Database 10g Release 2 manuals, you can find them online at http://www.oracle.com/pls/db102/homepage

  • Anyone know about perfect optimizer

    my firfox is not working so i need to reinstall firefox so I googled it said to install perfect optimizer but it cost $80.00 and it said it could fix 1000s of thing s help

    peeshy wrote:
    I had cleaned the keys prior to that with a damp cloth.  Do you think that's what messed it up?
    Probably.
    Under each key on the keyboard is a small wafer switch; got lots of those, plus printed circuitry, inside the keyboard. Only takes a little liquid getting inside to cause all kinds of short circuits amongst those switches and circuits, and it's not difficult to accidentally squeeze a few drops of water out of a damp cloth.
    Solution - if its a wired keyboard, unplug it; if it's wireless, remove the batteries. Then let it thoroughly dry; this may take a while, a couple of days perhaps, depending on the amount of liquid. You can use a fan to aid the drying process, but don't use heat, such as a blow dryer or even placing it in the sun.
    Plain water will not hurt the electrics inside a keyboard, provided there is no power applied to the keyboard.
    Many folk have been able to rinse coffee, soda, and other drink residue from out of a keyboard after a spill by immersing the keyboard in plain warm (not hot) water and sloshing it around a bit. After thorough drying the keyboard usually works fine. The main trick in such an accident is to get the spilled liquid out before any acids in it have had a chance to etch the copper inside, and/or before any dissolved sugers have had a chance to harden.

  • Question about 10g EM w/ 2 databases

    I've got 2 databases on one machine. How is EM supposed to be configured properly to see both of them?
    Right now I've got 2 directories under $ORACLE_HOME/<hostname>_<SID>, one per SID.

    Add the service names to OEM. You have to look for that option.
    Joel Pérez

  • 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.

Maybe you are looking for

  • Custom sub-screen creation in 'MRP 4' tab of MM01

    Hi All, I have to add custom sub-screens in u2018Accounting 2u2019, u2018MRP 2u2019 and u2018MRP 4u2019 tabs of the Material Master transaction (MM01). I could successfully add a sub-screen in u2018Accounting 2u2019, u2018MRP 2u2019 tabs by using SPR

  • How to keep photos in folders when removing from iOS?

    I usually use Preview on Mac to import photos and delete them from the iPad. I've started putting photos in folders but this organization is not maintained on import. Is there a way to maintain this when importing? Or even better: is there a way to l

  • How to set selectedIndex of a DropDownList bound to a DataGrid

    Hello I'm a newbie. Here my problem: I've two kind of objects, named Persona and Email. Persona has a one to many  relation with Email object. Persona is displayed in a DataGrid. Cliccking a row (a Persona item), I need to display all related emails

  • Serious UI issues in SQL Developer 4.0 for Mac

    I've encountered some serious UI issues in SQL Developer 4.0 for Mac (4.0.0.13) that impact it up to the point where it becomes unusable. If the database and tables are expanded in the "Connections" view, sometimes a node in the tree seems to become

  • Trouble with Servletrunner Utility.

    I downloaded the latest version of Java, Java 2 SDK 1.4.0_03. I have the J2SE latest version. I have a servlet. I am able to compile it successfully. I am not able to use the ServletRunner utility. Its not present in j2sdk1.4.0_03\bin. I have set the