GATHER_PLAN_STATISTICS

Hi all

Unfortunately, I am not able to understand why I can't see column E-lines and A-lines. Try to explain better:

(1) alter session:

ALTER session set statistics_level = "ALL".

(2) execution of the query with the indicator GATHER_PLAN_STATISTICS

explain plan for

Select / * + GATHER_PLAN_STATISTICS * / employe_id, last_name, job_id

employees

where job_id = "AD_VP."

(3) look at the plain execute:

SELECT plan_table_output

Of

TABLE (DBMS_XPLAN. Display ('plan_table', NULL, 'typical'))

(4) the output is

Hash value of plan: 1019430118

------------------------------------------------------------------------------------------

| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT |            |     2.    68.     2 (0) | 00:00:01 |

|   1.  TABLE ACCESS BY INDEX ROWID | EMPLOYEES |     2.    68.     2 (0) | 00:00:01 |

|*  2 |   INDEX RANGE SCAN | EMP_JOB_IX |     2.       |     1 (0) | 00:00:01 |

------------------------------------------------------------------------------------------

Information of predicates (identified by the operation identity card):

---------------------------------------------------

2 - access ("JOB_ID" = 'AD_VP')

Note

-----

-dynamic sample used for this survey (level = 2)

(5) I'd like to see the cardinality really A-LINES and the cardinality of estimante E-LINES;

but it is not this information; Why?

Thank you

Really a lot;

francy77 wrote:

I have run the query, the statistics fired but do not see A (ctual) line

No you have not run the query, at least not according to what you posted.  See if you can spot the differences between that and what you posted:

SQL > alter session set statistics_level = "ALL";

Modified session.

SQL > select / * + GATHER_PLAN_STATISTICS * /.
2 empno, ename
scott.emp 3
4 where deptno = 20;

EMPNO, ENAME
---------- ----------
7369 SMITH
7566 JONES
7788 SCOTT
7876 ADAMS
7902 FORD

SQL > select *.
table 2 (Dbms_Xplan.Display_Cursor (NULL, NULL, 'LAST ALLSTATS'));

PLAN_TABLE_OUTPUT
---------------------------------------------
SQL_ID, 4gkknj0n0y8dn, number of children 0
-------------------------------------
Select / * + GATHER_PLAN_STATISTICS * /.
EmpNo, ename
from scott.emp
where deptno = 20

Hash value of plan: 3956160932

---------------------------------------------------------------------------------------------
| ID | Operation | Name | Begins | E - lines. A - lines.   A - time | Pads | Bed |
---------------------------------------------------------------------------------------------
|*  1 |  TABLE ACCESS FULL | EMP |      1.      5.      5. 00:00:00.01 |       8.      6.
---------------------------------------------------------------------------------------------

Information of predicates (identified by the operation identity card):
---------------------------------------------------

1 - filter ("DEPTNO" = 20)

18 selected lines.

John

Tags: Database

Similar Questions

  • gather_plan_statistics index of no visible result

    on my Oracle 11.2.0.1, I tried to use this trick as in the example:
    set autotrace on explain
    select /*+ gather_plan_statistics */ 'x' from dual;
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 272002086
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    as you can see, there is no column extra (E-rows, A-lines), and I don't know why.
    What could cause this?

    concerning

    This is now another limitation to autotrace. Using dbms_xplan and format the data how you need.

    SQL> select /*+ gather_plan_statistics */ 'x' from dual;
    
    '
    -
    x
    
    SQL> SELECT * FROM table(dbms_xplan.display_cursor(format=>'allstats'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    SQL_ID  gxug7sz6nhqc3, child number 0
    -------------------------------------
    select /*+ gather_plan_statistics */ 'x' from dual
    
    Plan hash value: 1388734953
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Starts | E-Rows | A-Rows |   A-Time   |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |      4 |        |      4 |00:00:00.01 |
    |   1 |  FAST DUAL       |      |      4 |      1 |      4 |00:00:00.01 |
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    -------------------------------------------------------------------------
    
    13 rows selected.
    

    Learn more about the settings and use here:

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14258/d_xplan.htm

  • Column Rows, found when using / * + gather_plan_statistics * /.

    Hello

    does anyone know, whence the (e-rows) estimated_rows output information? I would check auto, when explaining use bad statistics.
    I know that it is inside the dbms_xplan.display.display package, but I would use it on a table-col
    By i´m looking for an exit way dbms_xplan who uses e-lines and cols and type = HTML. But I couldn t find it.

    Thank you

    Marco

    v$ sql_plan_statistics_all. Cardinality

  • Query, which returns lines adding up to a value in a column

    Hello

    You are looking for an application that will process and return only the many lines that add up to a special value on a column value.

    for example

    ID name date_joined allocated salary

    --        ------           ---------------     -------         ------------

    1 Tom January 1, 2010 1000 5000

    Dave 2 3000 5000 February 1, 2010

    3 Cindy 1000 5000 01-apr-2010

    4 Ian 01-mar-2010 1000 5000

    5         Matt          10 -jan-2010 1000-5000

    Return the lines where wages adding upto or beyond the value allocated to 5000, order by date_joined or more former employee first.

    The query should return:

    ID name date_joined allocated salary

    --        ------           ---------------     -------         ------------

    1 Tom January 1, 2010 1000 5000

    2         Matt          10 -jan-2010 1000-5000

    3         Ian            01-mar-2010 1000 5000

    Dave 4 3000 5000 February 1, 2010

    We do not want to deal with or include other lines summarizing calculation, would instead add first, if deficit adds to the line.

    Tried with lead, windowed with range UNLIMITED etc. that PRECEDES, that would not come up with good logic.

    I could make it work with PL/SQL, but do it in SQL turns out to be delicate.

    Thank you.

    A.

    Thanks for the input guys.

    Here, the ask is:

    1. how to treat only as lines that satisfy the "allocated" value, without treatment of all lines.

    > Thanks to Jarkko year John for the right direction.

    > RanitB thank you for your approach to the application of the model, I am not well versed with model query that I'll get to. But for the moment its not useful for me.

    2. to get only as much lines that are either less than or equal to 'assigned' value or satisfy "allocated", from less than "attributed" just beyond "allocated".

    (Sorry for the language, if its not very clear, I do not know how this fits better, following example should help demonstrate).

    I came up with the following code, although there could be best way to do it, I hope to see someone.

    {code: sql}

    create table t:

    Select object_name, join_dt, the salary of 1000 last_ddl_time, allocated 5500

    of object;

    Select

    / * gather_plan_statistics * / *.

    Of

    (select

    object_name, join_dt, salary, allocated, sofar, lag (sofar, 1, 0) over (order by join_dt) lag_sofar

    Of

    (select

    object_name, join_dt, salary, allocated,

    Salary on sofar (order by no_lig)

    Of

    (select object_name, join_dt, salary, allocated, row_number() on no_lig (order of join_dt) t) t - must do it has several join_dt even inputs (objects have same time ddl)

    )

    )

    where

    allocated > lag_sofar;

    OBJECT_NAME JOIN_DT SALARY  ALLOCATED SOFAR LAG_SOFAR
    SDO_TOPO_GEOMETRY 17 JULY 02

    1000

    5500 1000 0
    SI_AVERAGECOLOR 18 JULY 02 1000 5500 2000 1000
    SI_COLORHISTOGRAM 18 JULY 02 1000 5500 3000 2000
    SI_POSITIONALCOLOR 18 JULY 02 1000 5500 4000 3000
    SI_FEATURELIST 18 JULY 02 1000 5500 5000 4000
    SI_STILLIMAGE 18 JULY 02 1000 5500 6000 5000

    {code}

    Sorry for the bad formatting, I tried couple of code integration/formatting of tags, but could not get formatting just as many of you have done above.

    Can someone point me on the document where the tags for this type of formatting is present?

    For now I am marking my question as answered with my own response and that of the other answers as useful.

    If I get a better approach/solution I would mark it as correct.

  • Cursor_Sharing = Force and queries with literal comparisons forcing FTS

    Hi all

    I have the following scenario:

    • Oracle 11.2.0.3
    • A 3rd party application, requiring cursor_sharing = TRUE
    • A table (T2310) with an indexed field (C1000000161), which has no duplicate values
    • Cause the Mode Cache = force (don't think it's relevant in the present case, but its here to justify its appearance in the explain output)

    In this scenario, the 3rd party application run queries like the one below (I have to use the trick here, given that the explanation will not show the FTS):

            SQL> select /*+ GATHER_PLAN_STATISTICS */ C1000000161 
            > from aradmin.T2310 
            > where C1000000161 = 'INC000002137945' or ('a' = 'b');
    

    This type of query will eventually force a full table scan:

        SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
    
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------
        SQL_ID  f3njwvkb0yf1x, child number 0
        -------------------------------------
        select /*+ GATHER_PLAN_STATISTICS */ C1000000161 from
        aradmin.T2310 where C1000000161 = :"SYS_B_0" or (:"SYS_B_1"
        = :"SYS_B_2")
    
        Plan hash value: 1862236576
    
        --------------------------------------------------------------------------------------------------------------------
        | Id  | Operation          | Name                       | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
        --------------------------------------------------------------------------------------------------------------------
    
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------
        |   0 | SELECT STATEMENT   |                            |      1 |        |      0 |00:03:00.20 |    3964K|    161K|
        |   1 |  RESULT CACHE      | bkhyzz7n945syc4numpbs27y20 |      1 |        |      0 |00:03:00.20 |    3964K|    161K|
        |*  2 |   TABLE ACCESS FULL| T2310                      |      1 |  44030 |      0 |00:03:00.20 |    3964K|    161K|
        --------------------------------------------------------------------------------------------------------------------
    
        Predicate Information (identified by operation id):
        ---------------------------------------------------
    
           2 - filter((:SYS_B_1=:SYS_B_2 OR "T2310"."C1000000161"=:SYS_B_0))
    
        Result Cache Information (identified by operation id):
    
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------
        ------------------------------------------------------
    
           1 -
    

    As we can see in the explanation, literals are replaced with bind variables, and I think that it is forcing the FTS. If you remove the literal comparison, the index is used as intended.

    So my question is: is it possible to avoid this behavior on the side of the database?

    Thank you!

    As you say, we have two possible plans, we want to either that each row in the table or we want to use our predicate of the column. If we let the plan for both possibilities should have acceptable performance for the typical case (: SYS_B_1<>: SYS_B_2) and correct the results in the case of equality.

    If sql is rewritable I would do something like

    Select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =: b1
    and (: b2 <> : b3 or: b2 is null or: b3 is null)
    Union of all the
    Select C1000000161
    of t2310
    where: = b2: b3;

    The or_expand indicator (undocumented, but I find it more easy to set use_concat) could be useful to force the regime to take this shape without having to rewrite the query.

    create table t2310 (pk_col, C1000000161 VARCHAR2 (100 CHAR), constraint t2310_pk primary key (pk_col));
    create index t2310_161 on t2310 (C1000000161);
    Insert into t2310
    Select rownum, dbms_random.string ('U', 3) | To_char(rowNum,00000000000000)
    of the double
    connect by rownum<=>
    commit;
    exec dbms_Stats.gather_Table_stats (user, 't2310')
    ALTER session set cursor_sharing = force;

    Select / * + OR_EXPAND(t2310 C1000000161) GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 = 'INC000002137946' or ("a" = "b");
    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (FORMAT-ONLINE 'ALLSTATS LAST'));

    Hash value of plan: 928588817

    -------------------------------------------------------------------------------------------
    | ID | Operation | Name | Begins | E - lines. A - lines.  A - time | Pads |
    -------------------------------------------------------------------------------------------
    |  0 | SELECT STATEMENT |          |      1.        |      0 | 00:00:00.01 |      2.
    |  1.  CONCATENATION.          |      1.        |      0 | 00:00:00.01 |      2.
    |*  2 |  INDEX RANGE SCAN | T2310_161 |      1.      6.      0 | 00:00:00.01 |      2.
    |*  3 |  FILTER |          |      1.        |      0 | 00:00:00.01 |      0 |
    |*  4 |    TABLE ACCESS FULL | T2310 |      0 |  99994 |      0 | 00:00:00.01 |      0 |
    -------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - access("C1000000161"=:SYS_B_0)
    3 - filter(:SYS_B_1=:SYS_B_2)
    4 filter (LNNVL ("C1000000161" =: SYS_B_0))

    Now, you can use a plan for this sql database attach to the sql application:

    Select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 = 'INC000002137946' or ("a" = "b");
    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (FORMAT-ONLINE 'ALLSTATS LAST'));

    Hash value of plan: 1862236576

    -------------------------------------------------------------------------------------
    | ID | Operation | Name | Begins | E - lines. A - lines.  A - time | Pads |
    -------------------------------------------------------------------------------------
    |  0 | SELECT STATEMENT |      |      1.        |      0 | 00:00:00.03 |    248.
    |*  1 |  TABLE ACCESS FULL | T2310 |      1.  1006 |      0 | 00:00:00.03 |    248.
    -------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 Filter ((: SYS_B_1 =: SYS_B_2 or "C1000000161" =: SYS_B_0))

    @sql_find t2310

    CHILD_NUMBER PLAN_HASH_VALUE LAST_ACTIVE_TIME EXECUTIONS SQL_TEXT SQL_ID
    ------------- ------------ --------------- ------------------- ---------- ----------------------------------------------------------------------------------------------------
    34k49g78s1w5w 453626665 04/01/2016 0 22:55:11 1 Select / * + no_parallel_index (t, "T2310_PK") cursor_sharing_exact use_weak_name_resl dyn dbms_stats
    cnsa5smf77n8w 2274106110 04/01/2016 0 22:55:11 1 Select / * + no_parallel_index (t, "T2310_161") use_weak_name_resl cursor_sharing_exact, dbms_stats dy
    1cyhgv72abcf5 928588817 04/01/2016 0 22:55:11 1 Select / * + OR_EXPAND(t2310 C1000000161) GATHER_PLAN_STATISTICS * / t2310 C1000000161 where C1000
    gv84zvt3hagrk 1862236576 04/01/2016 0 22:55:11 1 Select / * + GATHER_PLAN_STATISTICS * / C1000000161 t2310 where C1000000161 =: 'SYS_B_0' or (: "SYS)
    2z5dv340ttwc3 0 0 01/04/2016-22:55:11 1 BEGIN dbms_Stats.gather_Table_stats (user, 't2310'); END;

    number of plans of var
    exec: plans: = dbms_spm.load_plans_from_cursor_cache(sql_id=>'gv84zvt3hagrk',plan_hash_value=>1862236576)

    print plans
    PLANS
    --------
    1

    Select the SQL_HANDLE column, plan_name, sql_Text dba_sql_plan_baselines;

    SQL_HANDLE PLAN_NAME SQL_TEXT
    ------------------------------ ------------------------------ ---------------------------------------------------------
    SQL_32cad750b449f08a SQL_PLAN_35kqra2u4mw4a24696a58 select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =
                   
                   
    exec: plans: = dbms_spm.load_plans_from_cursor_cache (sql_id-online '1cyhgv72abcf5', plan_hash_value-online 928588817, sql_handle => 'SQL_32cad750b449f08a')
    Select the SQL_HANDLE column, plan_name, sql_Text dba_sql_plan_baselines;
    SQL_HANDLE PLAN_NAME SQL_TEXT
    ------------------------------ ------------------------------ -----------------------------------------------------
    SQL_32cad750b449f08a SQL_PLAN_35kqra2u4mw4a24696a58 select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =

    SQL_32cad750b449f08a SQL_PLAN_35kqra2u4mw4af7b73bde select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =

    exec: plans: = dbms_spm.alter_sql_plan_baseline(sql_handle=>'SQL_32cad750b449f08a',plan_name=>'SQL_PLAN_35kqra2u4mw4a24696a58',attribute_name=>'enabled',attribute_value=>'NO')

    Select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 = 'INC000002137946' or ("a" = "b");
    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (FORMAT-ONLINE 'ALLSTATS LAST'));

    Hash value of plan: 928588817

    -------------------------------------------------------------------------------------------
    | ID | Operation | Name | Begins | E - lines. A - lines.  A - time | Pads |
    -------------------------------------------------------------------------------------------
    |  0 | SELECT STATEMENT |          |      1.        |      0 | 00:00:00.01 |      2.
    |  1.  CONCATENATION.          |      1.        |      0 | 00:00:00.01 |      2.
    |*  2 |  INDEX RANGE SCAN | T2310_161 |      1.      6.      0 | 00:00:00.01 |      2.
    |*  3 |  FILTER |          |      1.        |      0 | 00:00:00.01 |      0 |
    |*  4 |    TABLE ACCESS FULL | T2310 |      0 |  99994 |      0 | 00:00:00.01 |      0 |
    -------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - access("C1000000161"=:SYS_B_0)
    3 - filter(:SYS_B_1=:SYS_B_2)
    4 filter (LNNVL ("C1000000161" =: SYS_B_0))

    Note
    -----
    -Basic plan SQL SQL_PLAN_35kqra2u4mw4af7b73bde used for this statement

    As you can see, line 4 is running at all because of the filter in line 3 (start = 0 where id = 4)

  • Optimization of queries OR clause

    I'm using Oracle 12.1.0.2.

    I have a given below request that has 2 predicate with OR condition that contains text search in 2 tables (eir and eir_notes).    It takes 20 seconds.   The Charly come back in the second if I run the query with a single predicate without the GOLD clause.    Therefore, I solved it by the union to place where. I've included the two sql with the explain plan below command.

    Just for my knowledge, is there advice that I could use to make sql in OR more fast?

    Slow SQL with OR:

    SQL TEXT:

    SELECT  /*+ gather_plan_statistics
    */
          COUNT (*)
      FROM   (SELECT   eir.actn_tx
                FROM   EXAM_INCDT_RPT eir
               WHERE   (   contains (eir.prblm_tx, :1) > 0
                        OR eir.exam_incdt_rpt_id IN (SELECT /*+ qb_name( qb_sub_note)    */
                                                           exam_incdt_rpt_id
                                                       FROM   eir_note
                                                      WHERE   contains (note_tx, :2) > 0)))
    

    SQL_ID  8rwvqyphavc0c, child number 1
    -------------------------------------
    SELECT  /*+ gather_plan_statistics  */   COUNT (*)   FROM   (SELECT  
    eir.actn_tx              FROM   EXAM_INCDT_RPT eir            WHERE     
                       (   contains (eir.prblm_tx, :1) > 0 OR               
               eir.exam_incdt_rpt_id IN (SELECT /*+ qb_name( qb_sub_note)   
     */                                                          
    exam_incdt_rpt_id                                                       
     FROM   eir_note                                                       
    WHERE   contains (note_tx, :2) > 0)                                     
                      ))
    
    Plan hash value: 2956686415
    
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                             | Name           | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                      |                |      1 |        |       |  1343K(100)|          |      1 |00:00:20.24 |    1467K|   6770 |
    |   1 |  SORT AGGREGATE                       |                |      1 |      1 |   105 |            |          |      1 |00:00:20.24 |    1467K|   6770 |
    |*  2 |   FILTER                              |                |      1 |        |       |            |          |   5419 |00:00:21.28 |    1467K|   6770 |
    |   3 |    TABLE ACCESS FULL                  | EXAM_INCDT_RPT |      1 |    447K|    44M|  1343K  (1)| 00:01:45 |    447K|00:00:00.69 |    5819 |   5816 |
    |*  4 |    TABLE ACCESS BY INDEX ROWID BATCHED| EIR_NOTE       |    441K|      1 |   273 |     6   (0)| 00:00:01 |      2 |00:00:02.48 |     567K|    226 |
    |*  5 |     INDEX RANGE SCAN                  | EIR_NOTE_IX1   |    441K|      1 |       |     1   (0)| 00:00:01 |  10753 |00:00:01.65 |     535K|     20 |
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Query Block Name / Object Alias (identified by operation id):
    -------------------------------------------------------------
    
       1 - SEL$F5BB74E1
       3 - SEL$F5BB74E1 / EIR@SEL$2
       4 - QB_SUB_NOTE  / EIR_NOTE@QB_SUB_NOTE
       5 - QB_SUB_NOTE  / EIR_NOTE@QB_SUB_NOTE
    
    Outline Data
    -------------
    
      /*+
          BEGIN_OUTLINE_DATA
          IGNORE_OPTIM_EMBEDDED_HINTS
          OPTIMIZER_FEATURES_ENABLE('12.1.0.2')
          DB_VERSION('12.1.0.2')
          OPT_PARAM('_optim_peek_user_binds' 'false')
          ALL_ROWS
          OUTLINE_LEAF(@"QB_SUB_NOTE")
          OUTLINE_LEAF(@"SEL$F5BB74E1")
          MERGE(@"SEL$2")
          OUTLINE(@"QB_SUB_NOTE")
          OUTLINE(@"SEL$1")
          OUTLINE(@"SEL$2")
          FULL(@"SEL$F5BB74E1" "EIR"@"SEL$2")
          PQ_FILTER(@"SEL$F5BB74E1" SERIAL)
          INDEX_RS_ASC(@"QB_SUB_NOTE" "EIR_NOTE"@"QB_SUB_NOTE" ("EIR_NOTE"."EXAM_INCDT_RPT_ID"))
          BATCH_TABLE_ACCESS_BY_ROWID(@"QB_SUB_NOTE" "EIR_NOTE"@"QB_SUB_NOTE")
          END_OUTLINE_DATA
      */
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(("CTXSYS"."CONTAINS"("EIR"."PRBLM_TX",:1)>0 OR  IS NOT NULL))
       4 - filter("CTXSYS"."CONTAINS"("NOTE_TX",:2)>0)
       5 - access("EXAM_INCDT_RPT_ID"=:B1)
    
    Column Projection Information (identified by operation id):
    -----------------------------------------------------------
    
       1 - (#keys=0) COUNT(*)[22]
       3 - "EIR".ROWID[ROWID,10], "EIR"."EXAM_INCDT_RPT_ID"[NUMBER,22], "EIR"."PRBLM_TX"[LOB,4000]
       5 - "EIR_NOTE".ROWID[ROWID,10]
    

    Explain the plan of sql with union

    SQL TEXT:

    SELECT /*+ gather_plan_statistics */
          COUNT (*)
      FROM   (SELECT   *
                FROM   EXAM_INCDT_RPT eir
               WHERE   contains (eir.prblm_tx, :1) > 0
              UNION ALL
              SELECT   *
                FROM   EXAM_INCDT_RPT
               WHERE   exam_incdt_rpt_id IN (SELECT   exam_incdt_rpt_id
                                               FROM   eir_note
                                              WHERE   contains (note_tx, :2) > 0))
    
    
    

    The use_concat flag may be appropriate.

    https://docs.Oracle.com/database/121/SQLRF/sql_elements006.htm#BABIAFIB

    The USE_CONCAT index tells the optimizer to transform handset OR -the economic situation in the WHERE clause of a query in a composite application using the UNION ALL fixed operator. Without this indication, this transformation only occurs if the query using concatenations is less expensive than the cost without them. The USE_CONCAT Council overrides consideration of cost. For example:

    SELECT /*+ USE_CONCAT */ * FROM employees e WHERE manager_id = 108 OR department_id = 110;
    
  • SQLPlus BACK: Cannot set linesize

    Hello

    I'm trying to set linesize for my plan to explain, but unable to do so. Can someone please tell me what I might be missing here?

    SQL> set linesize 300
    SQL> explain plan for select /*+ GATHER_PLAN_STATISTICS */  count(*), shipto from libr_tbl group by shipto;
    
    
    Explained.
    
    
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY(FORMAT=>'ALLSTATS LAST'));
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------
    Plan hash value: 1488474053
    
    
    ------------------------------------------------
    | Id  | Operation          | Name     | E-Rows |
    ------------------------------------------------
    |   0 | SELECT STATEMENT   |          |   3000 |
    |   1 |  HASH GROUP BY     |          |   3000 |
    |   2 |   TABLE ACCESS FULL| LIBR_TBL |   3000 |
    ------------------------------------------------
    
    
    Note
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------
    -----
       - dynamic sampling used for this statement (level=2)
       - Warning: basic plan statistics not available. These are only collected when:
           * hint 'gather_plan_statistics' is used for the statement or
           * parameter 'statistics_level' is set to 'ALL', at session or system level
    
    
    16 rows selected.
    
    
    SQL>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    With the help of Windows7, Oracle 11.2

    Thank you

    SQL > explain plan for select / * + gather_plan_statistics * / * employees;

    He explained.

    SQL > select * from table (dbms_xplan.display (null, null, 'ALLSTATS LAST'));

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------

    Hash value of plan: 1445457117

    ------------------------------------------------

    | ID | Operation | Name | E - lines.

    ------------------------------------------------

    |   0 | SELECT STATEMENT |           |    107.

    |   1.  TABLE ACCESS FULL | EMPLOYEES |    107.

    ------------------------------------------------

    Note

    -----

    -WARNING: basic plan not available statistics. This are only collected when:

    * Board "gather_plan_statistics" is used for instruction or

    * the "statistics_level" setting is set to "ALL", at the level of the session or system

    ----------------------------------------------------------------

    SQL > select / * + gather_plan_statistics * / * employees;

    EMPLOYEE_ID FIRST NAME LAST NAME

    -------------------- -------------------- -------------------------

    Steven King 100

    Neena 101 Kochhar

    Cock lex 102

    Alexander 103 Hunold

    ....

    SQL > select * from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));

    PLAN_TABLE_OUTPUT

    ------------------------------------------------------------------------------------------------

    SQL_ID, dsgxq1c7cs749, number of children 0

    -------------------------------------

    Select / * + gather_plan_statistics * / * employees

    Hash value of plan: 1445457117

    -----------------------------------------------------------------------------------------

    | ID | Operation | Name | Begins | E - lines. A - lines.   A - time | Pads |

    -----------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |           |      1.        |    107. 00:00:00.01 |      15.

    |   1.  TABLE ACCESS FULL | EMPLOYEES |      1.    107.    107. 00:00:00.01 |      15.

    -----------------------------------------------------------------------------------------

    13 selected lines.

  • VECTOR_TRANSFORM and ORACLE 12 c InMemory

    Patch level: "game of hotfixes in the OCW - updated: 12.1.0.2.4 (20831113).

    Like many people I guess, I just upgraded an existing DWH, I set some 12 c in memory settings and expect significant performance improvements.

    It did not.

    So I decided to build a DWH sample with a time and the product dimension and a partitioned fact table that is so great that it would not completely fit in the inmemory part, to do some tests in a much simpler environment.

    In my example, the dimensions are first loaded in memory in priority. The fact load depends on the use of partitions so that the 'real' data will not fit.

    Questions I wanted to answer were:
    1. the inmemory query will be much faster than the no version inmemory. (Answer: it depends.) It is often not!)
    2 done ORACLE Exchange will introduce INMEMORY partitions when there is no more space and
    other data partitions (for example in the form of a FIFO?), we wonder. (Answer: no, this is documented)
    3. will I see in v$ im_segments I have no partitions of all the senses in memory
    (No you need to associate DBA_SEGMENTS to see the partitions in memory.)

    Now, I tried to find out why I have no more success.


    And while I played and I read, I found VECTOR_TRANSFORM
    https://support.Oracle.com/epmos/faces/DocumentDisplay?_afrLoop=287258785184897 & ID = 1935305.1 & _afrWindowMode = 0 & _adf. CTRL-State = 15o1gcrocb_55
    WHO gave a real helping hand to my request! (when the optimizer takes)

    I set myself (to have always to all my normal queries of DWH)
    change all of the "_always_vector_transformation" system = true;
    change the whole system "_optimizer_vector_cost_adj" = 20;

    But it does not work for all queries.

    So I decided to share my findings with you and ask if anyone knows why ORACLE here sometimes decide not to use VECTOR_TRANSFORM.

    I have found too much examples of work on the WEB that really show the difference in performance of INMEMORY. I did it here hope for other examples of work / tips etc.

    Here in short my tests and you see that I am MUCH faster when both functions are used.


    Without VECTOR_TRANSFORM and INMEMORY
    Elapsed time: 00:00:38.56
    A query that takes VECTOR_TRANSFORM and INMEMORY is:
    Elapsed time: 00:00:00.75 < = factor 50 and VERY impressive!
    Without VECTOR_TRANSFORM with INMEMORY
    Elapsed time: 00:00:09.32
    Even if the fact is not in memory query takes:
    Elapsed time: 00:00:02.79

    Then, as my system memory is limited, I would put all the dimensions of INMEMORY and
    hope that the VECTOR_TRANSFORM is ALWAYS used

    But even I put '_always_vector_transformation' and give a clue VECTOR_TRANSFORM.
    VECTOR_TRANSFORM is sometimes not used.

    I put the events below to get an answer and checked the trace:
    ALTER session set events trace [SQL_Transform.*] ' disk 'high '.
    ALTER session set events trace [SQL_Costing.*] ' disk 'high '.

    but that didn't help either. (too much information ;-)

    My settings (SOLARIS 10, Intel x 64, 64 CPU, the memory of the 1 TB server)

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    inmemory_force string by DEFAULT
    inmemory_max_populate_servers integer 12
    inmemory_query string ENABLE
    inmemory_size big integer 1 G
    inmemory_trickle_repopulate_servers_ integer 50
    percent
    optimizer_inmemory_aware Boolean TRUE
    SGA_MAX_SIZE large whole 20G
    Whole large SGA_TARGET 20G

    _always_vector_transformation Boolean TRUE


    The DWH, which you can build yourself with the following size

    (The fact table has 4000 'days' / data using 32 GB partitions)

    NOM_SEGMENT MO COUNT (*)
    -------------------------- ----------
    32000 4000 SALES_FACT
    0 1 DAY_DIMENSION
    2 1 PRODUCT_DIMENSION

    (If you don't not have 32 GB to use, it is easy to make the smaller example.)

    PKs and constraints have been fixed.
    Statistics with histograms on indexed lines, or on day_dimension, all areas are taken to give the optimizer everthing he might need.

    Thank you for thinking about it.
    Andy

    Queries:
    --------

    -Q1:
    ------
    Select
    min (d.day_id), Max (d.day_id),
    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)
    of day_dimension d
    inner join sales_fact f
    on d.day_id = f.day_id
    inner join product_dimension p
    on p.product_id = f.product_id
    where d.year = 2012
    and p.product_type = 'TABLE'
    D.year group, p.product_type
    d.year order, p.product_type;
    -Elapsed: 00:00:00.75

    -Q2: what 'min' is missing in the VECTOR_TRANSFORM SQL does NOT.
    ------
    Select / * + VECTOR_TRANSFORM * /.
    -min (d.day_id), max (d.day_id),
    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)
    of day_dimension d
    inner join sales_fact f
    on d.day_id = f.day_id
    inner join product_dimension p
    on p.product_id = f.product_id
    where d.year = 2012
    and p.product_type = 'TABLE'
    D.year group, p.product_type
    d.year order, p.product_type;
    -Elapsed: 00:00:09.32

    -Q3: what 'min' is missing in the VECTOR_TRANSFORM SQL is NOT without INMOMRY, it is slow.
    ------
    Select / * + VECTOR_TRANSFORM NO_INMEMORY * /.
    -min (d.day_id), max (d.day_id),
    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)
    of day_dimension d
    inner join sales_fact f
    on d.day_id = f.day_id
    inner join product_dimension p
    on p.product_id = f.product_id
    where d.year = 2012
    and p.product_type = 'TABLE'
    D.year group, p.product_type
    d.year order, p.product_type;
    -Elapsed: 00:00:38.78


    -Q4:
    ------
    Select / * + VECTOR_TRANSFORM NO_INMEMORY * /.
    min (d.day_id), Max (d.day_id),
    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)
    of day_dimension d
    inner join sales_fact f
    on d.day_id = f.day_id
    inner join product_dimension p
    on p.product_id = f.product_id
    where d.year = 2012
    and p.product_type = 'TABLE'
    D.year group, p.product_type
    d.year order, p.product_type;
    -Elapsed: 00:00:01.03

    -Q5:
    -----
    Select / * + NO_VECTOR_TRANSFORM NO_INMEMORY * /.
    min (d.day_id), Max (d.day_id),
    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)
    of day_dimension d
    inner join sales_fact f
    on d.day_id = f.day_id
    inner join product_dimension p
    on p.product_id = f.product_id
    where d.year = 2012
    and p.product_type = 'TABLE'
    D.year group, p.product_type
    d.year order, p.product_type;
    -Elapsed: 00:00:38.56

    -Q6: (done partitoned for 2014 not in memory)
    ------
    Select
    min (d.day_id), Max (d.day_id),
    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)
    of day_dimension d
    inner join sales_fact f
    on d.day_id = f.day_id
    inner join product_dimension p
    on p.product_id = f.product_id
    where d.year = 2014
    and p.product_type = 'TABLE'
    D.year group, p.product_type
    d.year order, p.product_type;
    -Elapsed: 00:00:02.70

    Q1:
    -----------------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name                        | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    -----------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |                             |   259. 20720 |   176K (57) | 00:00:28 |       |       |
    |   1.  TRANSFORMATION OF THE TEMPORARY TABLE.                             |       |       |            |          |       |       |
    |   2.   LOAD SELECT ACE | SYS_TEMP_0FD9D6928_73F9117C |       |       |            |          |       |       |
    |   3.    GROUP BY VECTOR |                             |   366.  2928.     1 (0) | 00:00:01 |       |       |
    |   4.     VECTOR KEY CREATE BUFFER | : KV0000 |       |       |            |          |       |       |
    |*  5 |      INMEMORY COMPLETE ACCESS TABLE | DAY_DIMENSION |   366.  2928.     1 (0) | 00:00:01 |       |       |
    |   6.   LOAD SELECT ACE | SYS_TEMP_0FD9D6929_73F9117C |       |       |            |          |       |       |
    |   7.    GROUP BY VECTOR |                             |     1.    12.     1 (0) | 00:00:01 |       |       |
    |   8.     HASH GROUP BY.                             |     1.    12.     1 (0) | 00:00:01 |       |       |
    |   9.      VECTOR KEY CREATE BUFFER | : KV0001 |       |       |            |          |       |       |
    | * 10 |       INMEMORY COMPLETE ACCESS TABLE | PRODUCT_DIMENSION |   888. 10656.     1 (0) | 00:00:01 |       |       |
    |  11.   GROUP SORT BY NOSORT |                             |   259. 20720 |   176K (57) | 00:00:28 |       |       |
    | * 12 |    HASH JOIN |                             |   259. 20720 |   176K (57) | 00:00:28 |       |       |
    |  13.     THE CARTESIAN MERGE JOIN.                             |   366.  7320 |     4 (0) | 00:00:01 |       |       |
    |  14.      TABLE ACCESS FULL | SYS_TEMP_0FD9D6929_73F9117C |     1.    12.     2 (0) | 00:00:01 |       |       |
    |  15.      KIND OF BUFFER.                             |   366.  2928.     2 (0) | 00:00:01 |       |       |
    |  16.       TABLE ACCESS FULL | SYS_TEMP_0FD9D6928_73F9117C |   366.  2928.     2 (0) | 00:00:01 |       |       |
    |  17.     VIEW                            | VW_VT_4FBA27B6 |   259. 15540 |   176K (57) | 00:00:28 |       |       |
    |  18.      GROUP BY VECTOR |                             |   259.  3367 |   176K (57) | 00:00:28 |       |       |
    |  19.       HASH GROUP BY.                             |   259.  3367 |   176K (57) | 00:00:28 |       |       |
    |  20.        USE OF KEY VECTORS | : KV0000 |       |       |            |          |       |       |
    |  21.         USE OF KEY VECTORS | : KV0001 |       |       |            |          |       |       |
    |  22.          RANGE OF PARTITION SUBQUERY |                             |   160 M |  1983M | 77948 (2) | 00:00:13 | KEY (SQ) | KEY (SQ) |
    | * 23.           INMEMORY COMPLETE ACCESS TABLE | SALES_FACT |   160 M |  1983M | 77948 (2) | 00:00:13 | KEY (SQ) | KEY (SQ) |
    -----------------------------------------------------------------------------------------------------------------------------------

    Q2:
    ---------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    ---------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |                   |  1308K |    41 M | 78385 (2) | 00:00:13 |       |       |
    |   1.  GROUP SORT BY NOSORT |                   |  1308K |    41 M | 78385 (2) | 00:00:13 |       |       |
    |*  2 |   HASH JOIN |                   |  1308K |    41 M | 78385 (2) | 00:00:13 |       |       |
    |   3.    JOIN FILTER PART CREATE | : BF0000 |   366.  2928.     1 (0) | 00:00:01 |       |       |
    |*  4 |     INMEMORY COMPLETE ACCESS TABLE | DAY_DIMENSION |   366.  2928.     1 (0) | 00:00:01 |       |       |
    |*  5 |    HASH JOIN |                   |    14 M |   341 M | 78349 (2) | 00:00:13 |       |       |
    |   6.     JOIN CREATE FILTER | : BF0001 |   888. 10656.     1 (0) | 00:00:01 |       |       |
    |*  7 |      INMEMORY COMPLETE ACCESS TABLE | PRODUCT_DIMENSION |   888. 10656.     1 (0) | 00:00:01 |       |       |
    |   8.     USE OF JOIN FILTER | : BF0001 |   160 M |  1983M | 77948 (2) | 00:00:13 |       |       |
    |   9.      RANGE OF PARTITION-JOIN FILTER |                   |   160 M |  1983M | 77948 (2) | 00:00:13 | : BF0000 | : BF0000 |
    | * 10 |       INMEMORY COMPLETE ACCESS TABLE | SALES_FACT |   160 M |  1983M | 77948 (2) | 00:00:13 | : BF0000 | : BF0000 |
    ---------------------------------------------------------------------------------------------------------------------

    Q3:
    --------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    --------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |                   |  1308K |    41 M | 85288 (2) | 00:00:14 |    |          |
    |   1.  GROUP SORT BY NOSORT |                   |  1308K |    41 M | 85288 (2) | 00:00:14 |    |          |
    |*  2 |   HASH JOIN |                   |  1308K |    41 M | 85288 (2) | 00:00:14 |    |          |
    |   3.    JOIN FILTER PART CREATE | : BF0000 |   366.  2928.     4 (0) | 00:00:01 |    |          |
    |*  4 |     TABLE ACCESS FULL | DAY_DIMENSION |   366.  2928.     4 (0) | 00:00:01 |    |          |
    |*  5 |    HASH JOIN |                   |    14 M |   341 M | 85248 (2) | 00:00:14 |    |          |
    |*  6 |     TABLE ACCESS FULL | PRODUCT_DIMENSION |   888. 10656.     9 (0) | 00:00:01 |    |          |
    |   7.     RANGE OF PARTITION-JOIN FILTER |                   |   160 M |  1983M | 84839 (2) | 00:00:14 | : BF0000 | : BF0000 |
    |   8.      TABLE ACCESS FULL | SALES_FACT |   160 M |  1983M | 84839 (2) | 00:00:14 | : BF0000 | : BF0000 |
    --------------------------------------------------------------------------------------------------------------------

    Q4:
    -----------------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name                        | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    -----------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |                             |   259. 20720 |   176K (57) | 00:00:28 |       |       |
    |   1.  TRANSFORMATION OF THE TEMPORARY TABLE.                             |       |       |            |          |       |       |
    |   2.   LOAD SELECT ACE | SYS_TEMP_0FD9D6936_73F9117C |       |       |            |          |       |       |
    |   3.    GROUP BY VECTOR |                             |   366.  2928.     1 (0) | 00:00:01 |       |       |
    |   4.     VECTOR KEY CREATE BUFFER | : KV0000 |       |       |            |          |       |       |
    |*  5 |      INMEMORY COMPLETE ACCESS TABLE | DAY_DIMENSION |   366.  2928.     1 (0) | 00:00:01 |       |       |
    |   6.   LOAD SELECT ACE | SYS_TEMP_0FD9D6937_73F9117C |       |       |            |          |       |       |
    |   7.    GROUP BY VECTOR |                             |     1.    12.     1 (0) | 00:00:01 |       |       |
    |   8.     HASH GROUP BY.                             |     1.    12.     1 (0) | 00:00:01 |       |       |
    |   9.      VECTOR KEY CREATE BUFFER | : KV0001 |       |       |            |          |       |       |
    | * 10 |       INMEMORY COMPLETE ACCESS TABLE | PRODUCT_DIMENSION |   888. 10656.     1 (0) | 00:00:01 |       |       |
    |  11.   GROUP SORT BY NOSORT |                             |   259. 20720 |   176K (57) | 00:00:28 |       |       |
    | * 12 |    HASH JOIN |                             |   259. 20720 |   176K (57) | 00:00:28 |       |       |
    |  13.     THE CARTESIAN MERGE JOIN.                             |   366.  7320 |     4 (0) | 00:00:01 |       |       |
    |  14.      TABLE ACCESS FULL | SYS_TEMP_0FD9D6937_73F9117C |     1.    12.     2 (0) | 00:00:01 |       |       |
    |  15.      KIND OF BUFFER.                             |   366.  2928.     2 (0) | 00:00:01 |       |       |
    |  16.       TABLE ACCESS FULL | SYS_TEMP_0FD9D6936_73F9117C |   366.  2928.     2 (0) | 00:00:01 |       |       |
    |  17.     VIEW                            | VW_VT_4FBA27B6 |   259. 15540 |   176K (57) | 00:00:28 |       |       |
    |  18.      GROUP BY VECTOR |                             |   259.  3367 |   176K (57) | 00:00:28 |       |       |
    |  19.       HASH GROUP BY.                             |   259.  3367 |   176K (57) | 00:00:28 |       |       |
    |  20.        USE OF KEY VECTORS | : KV0000 |       |       |            |          |       |       |
    |  21.         USE OF KEY VECTORS | : KV0001 |       |       |            |          |       |       |
    |  22.          RANGE OF PARTITION SUBQUERY |                             |   160 M |  1983M | 77948 (2) | 00:00:13 | KEY (SQ) | KEY (SQ) |
    | * 23.           INMEMORY COMPLETE ACCESS TABLE | SALES_FACT |   160 M |  1983M | 77948 (2) | 00:00:13 | KEY (SQ) | KEY (SQ) |
    -----------------------------------------------------------------------------------------------------------------------------------

    Q5:
    --------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    --------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |                   |  1308K |    41 M | 85288 (2) | 00:00:14 |    |          |
    |   1.  GROUP SORT BY NOSORT |                   |  1308K |    41 M | 85288 (2) | 00:00:14 |    |          |
    |*  2 |   HASH JOIN |                   |  1308K |    41 M | 85288 (2) | 00:00:14 |    |          |
    |   3.    JOIN FILTER PART CREATE | : BF0000 |   366.  2928.     4 (0) | 00:00:01 |    |          |
    |*  4 |     TABLE ACCESS FULL | DAY_DIMENSION |   366.  2928.     4 (0) | 00:00:01 |    |          |
    |*  5 |    HASH JOIN |                   |    14 M |   341 M | 85248 (2) | 00:00:14 |    |          |
    |*  6 |     TABLE ACCESS FULL | PRODUCT_DIMENSION |   888. 10656.     9 (0) | 00:00:01 |    |          |
    |   7.     RANGE OF PARTITION-JOIN FILTER |                   |   160 M |  1983M | 84839 (2) | 00:00:14 | : BF0000 | : BF0000 |
    |   8.      TABLE ACCESS FULL | SALES_FACT |   160 M |  1983M | 84839 (2) | 00:00:14 | : BF0000 | : BF0000 |
    --------------------------------------------------------------------------------------------------------------------

    Updated the DWH:


    create the table day_dimension
    as
    WITH my_days like)
    LEVEL SELECT ID, trunc (sysdate)-3900 + LEVEL my_day
    OF THE DOUBLE
    CONNECT BY LEVEL < = 4000)
    --
    Select
    ID day_id,
    my_day current_day,
    TO_NUMBER (to_char(my_day,'YYYYMM')) month_id,
    TO_NUMBER (to_char(my_day,'YYYY')) year,
    to_char(my_day,'DAY') day_name,
    to_char(my_day,'MONTH') month_name,
    TO_CHAR (my_day, ' DAY DDMONTH ',' NLS_DATE_LANGUAGE = GERMAN ') german_day,.
    TO_CHAR (my_day, ' DAY DDMONTH ',' NLS_DATE_LANGUAGE = FRENCH ') french_day,.
    -case when my_day = trunc (sysdate) then 'Y' else ' n end current_day_flag.
    cases where last_day (my_day) = my_day then 'Y' else ' n end month_end_flag.
    MONTHS_BETWEEN (LAST_DAY (my_day), LAST_DAY (sysdate)) months_back
    Of
    my_days;

    ALTER table day_dimension ADD CONSTRAINT day_pk PRIMARY KEY (day_id) USING INDEX;


    create the table product_dimension
    as
    Select product_id, product_name object_name, object_type product_type rownum,
    object_name | » -'|| object_name | » -'|| object_name | » -'|| object_name | » -'|| object_name | » -'|| object_name product_name_long
    from dba_objects where rownum < = 10000;

    ALTER table product_dimension ADD CONSTRAINT prod_pk PRIMARY KEY (product_id) USING INDEX;


    drop table sales_fact;
    create the table sales_fact
    (day_id NUMBER (15.0) NOT NULL,)
    product_id NUMBER (15.0) NOT NULL,
    sale_price number,
    filler_text VARCHAR2 (1000))
    PARTITION OF RANGE (day_id) INTERVAL (1)
    (PARTITION "PMIN" VALUES LOWER (1) SEGMENT DEFERRED CREATION)
    ;

    ALTER table sales_fact add constraint day_id_fk foreign (day_id) keys
    disable the references day_dimension (day_id);

    ALTER table sales_fact add constraint product_id_fk foreign (product_id) keys
    disable the references product_dimension (product_id);


    Insert into sales_fact (product_id, sale_price, day_id, filler_text)
    SELECT 1 day_id
    trunc (DBMS_RANDOM. VALUE * 10000) product_id,.
    Round (DBMS_RANDOM. VALUE * 1000, 2) sale_price;
    Filler_text "the PL/SQL interface for components of the Advisor is described at the end of this article"
    OF THE DOUBLE
    CONNECT BY LEVEL < = 40000;
    commit;

    Start
    because me 2.4000 loop
    Insert into sales_fact (product_id, sale_price, day_id, filler_text)
    Select I product_id, sale_price, filler_text from sales_fact where day_id = 1;
    commit;

    end loop;
    end;
    /

    -get statistics:

    Start
    DBMS_STATS. () GATHER_TABLE_STATS
    ownname = > 'DWHADM ',.
    tabname = > 'DAY_DIMENSION ',.
    method_opt = > 'for all THE COLUMNS of SIZE AUTO. "
    block_sample = > TRUE,
    Cascade = > TRUE);
    end;
    /


    Start
    I'm in (select * from all_tables where table_name in ('SALES_FACT', 'PRODUCT_DIMENSION')) loop
    DBMS_STATS. () GATHER_TABLE_STATS
    ownname = > i.owner,
    tabname = > i.table_name,
    block_sample = > TRUE,
    level = > 4,
    Cascade = > TRUE);

    end loop;
    end;
    /

    Andy,

    I built your model with a few adjustments and played a little bit.

    I did not have the dimensions in memory and I added an extra column to the product dimension, and I built only 254 partitions (so all in 2005)

    I think the optimizer ignores the vector transformation because he decides that your request is not a query group. Your entry is:

    Select

    -min (d.day_id), max (d.day_id),

    d.Year, p.product_type, sum (f.sale_price) sale_price, count (*)

    of day_dimension d

    sales_fact f d.day_id = f.day_id inner join

    inner join product_dimension p on p.product_id = f.product_id

    where d.year = 2012 and p.product_type = 'TABLE '.

    D.year group, p.product_type

    d.year order, p.product_type

    The optimizer rewrites that:

    Select

    2012, 'TABLE', sum (f.sale_price) sale_price, count (*)

    of day_dimension d

    sales_fact f d.day_id = f.day_id inner join

    inner join product_dimension p on p.product_id = f.product_id

    where d.year = 2012 and p.product_type = 'TABLE '.

    2012 group

    It seems to me that if he had to eliminate "Group by constant", and it is strange that she keeps the first two columns (switch provided that the order in the group by and rewriting will be "Group by 'TABLE'")

    I think that, even if, to some Oracle processes a query point block this exliminates that "group by" and disables VT accordingly.

    My clue, incidentally was wrong, I realized it to @sel$ 1 when it should have been directed to joining 3 tables merged.

    The subquery indicator (even if she had worn on the right query block) not would not have worked because it seems that creating a filter of Bloom for elimination of partition overrides subquery filtering - at least in 12.1.0.2 - and if the day_dimension is used as a table of accumulation, it is automatically able to generate a Bloom filter , and the no_px_join_filter() applies only for the join filter, not for the elimination of partition filter.

    One thing I found with this request, however, is that if I disabled it partition pruning by filter Bloom (OPT_PARAM ('_bloom_pruning_enabled' 'false')) then, on the my data set, he ran a little faster. I would be interested in what he does on your game. (With statistics_level a new typical and no index of gather_plan_statistics).  Possibly the most robust test would be the next set of indicators - to change the 'swap' to 'no_swap '.

    /*+

    attack (@sel$ 9e43cb6e p@sel$2 f@sel$1 d@sel$1)

    px_join_filter (@sel$ 9e43cb6e f@sel$1)

    subquery_pruning (@sel$ 9e43cb6e f@sel$1 partition)

    USE_HASH (@sel$ 9e43cb6e f@sel$1)

    USE_HASH (@sel$ 9e43cb6e d@sel$1)

    swap_join_inputs (@sel$ 9e43cb6e d@sel$1)

    */

    Here are the plans of running two I - the first was traded, the second is not exchanged:

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Begins | E - lines. Cost (% CPU). Pstart. Pstop | A - lines.  A - time | Pads | Bed |  OMem |  1Mem | Used Mem.

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    |  0 | SELECT STATEMENT |                  |      1.        | 15086 (100) |      |      |      1. 00:00:39.24 |  50527 |  48906 |      |      |          |

    |  1.  GROUP SORT BY NOSORT |                  |      1.    639K | 15086 (1) |      |      |      1. 00:00:39.24 |  50527 |  48906 |      |      |          |

    |*  2 |  HASH JOIN |                  |      1.    639K | 15086 (1) |      |      |  1221K | 00:00:36.49 |  50527 |  48906 |  2440K |  2440K | 1472K (0) |

    |  3.    JOIN FILTER PART CREATE | : BF0000 |      1.    333.    18 (0) |      |      |    333. 00:00:00.01 |      57.      0 |      |      |          |

    |*  4 |    TABLE ACCESS FULL | DAY_DIMENSION |      1.    333.    18 (0) |      |      |    333. 00:00:00.01 |      57.      0 |      |      |          |

    |*  5 |    HASH JOIN |                  |      1.    641K | 15066 (1) |      |      |  1221K | 00:00:26.16 |  50470 |  48906 |  2440K |  2440K | 1184K (0) |

    |  6.    JOIN CREATE FILTER | : BF0001 |      1.    625.    61 (0) |      |      |  1210 | 00:00:00.01 |    214.      0 |      |      |          |

    |*  7 |      TABLE ACCESS FULL | PRODUCT_DIMENSION |      1.    625.    61 (0) |      |      |  1210 | 00:00:00.01 |    214.      0 |      |      |          |

    |  8.    USE OF JOIN FILTER | : BF0001 |      1.    10 M | 14981 (1) |      |      |  1389K | 00:00:14.92 |  50256 |  48906 |      |      |          |

    |  9.      RANGE OF PARTITION-JOIN FILTER |                  |      1.    10 M | 14981 (1) | : BF0000 | : BF0000 |  1389K | 00:00:09.30 |  50256 |  48906 |      |      |          |

    | * 10 |      INMEMORY COMPLETE ACCESS TABLE | SALES_FACT |    254.    10 M | 14981 (1) | : BF0000 | : BF0000 |  1389K | 00:00:03.72 |  50256 |  48906 |      |      |          |

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - access("D".") "DAY_ID" ="F" DAY_ID')

    4 - filter("D".") AN "= 2005)

    5 - access("P".") ' PRODUCT_ID ' =' F '" PRODUCT_ID')

    7 - filter("P".") PRODUCT_TYPE "=" TABLE")

    10 - inmemory (SYS_OP_BLOOM_FILTER (: BF0000, 'F'.)) ((' ' PRODUCT_ID '))

    filter (SYS_OP_BLOOM_FILTER (: BF0000, 'F'.)) ((' ' PRODUCT_ID '))

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Begins | E - lines. Cost (% CPU). Pstart. Pstop | A - lines.  A - time | Pads | Bed |  OMem |  1Mem | Used Mem.

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                   |      1.        | 16180 (100) |      |      |      1. 00:00:07.47 |  50584 |  48956 |      |      |          |

    |   1.  GROUP SORT BY NOSORT |                   |      1.    639K | 16180 (1) |      |      |      1. 00:00:07.47 |  50584 |  48956 |      |      |          |

    |*  2 |   HASH JOIN |                   |      1.    639K | 16180 (1) |      |      |  1221K | 00:00:04.88 |  50584 |  48956 |    88.  9683K |  78 M (0).

    |*  3 |    HASH JOIN |                   |      1.    641K | 15066 (1) |      |      |  1221K | 00:00:01.88 |  50527 |  48956 |  2440K |  2440K | 1134K (0) |

    |   4.     JOIN CREATE FILTER | : BF0000 |      1.    625.    61 (0) |      |      |  1210 | 00:00:00.01 |    214.      0 |      |      |          |

    |*  5 |      TABLE ACCESS FULL | PRODUCT_DIMENSION |      1.    625.    61 (0) |      |      |  1210 | 00:00:00.01 |    214.      0 |      |      |          |

    |   6.     USE OF JOIN FILTER | : BF0000 |      1.    10 M | 14981 (1) |      |      |  1389K | 00:00:01.25 |  50313 |  48956 |      |      |          |

    |   7.      RANGE OF PARTITION SUBQUERY |                   |      1.    10 M | 14981 (1) | KEY (SQ) | KEY (SQ) |  1389K | 00:00:01.03 |  50313 |  48956 |      |      |          |

    |*  8 |       INMEMORY COMPLETE ACCESS TABLE | SALES_FACT |    254.    10 M | 14981 (1) | KEY (SQ) | KEY (SQ) |  1389K | 00:00:00.78 |  50256 |  48956 |      |      |          |

    |*  9 |    TABLE ACCESS FULL | DAY_DIMENSION |      1.    333.    18 (0) |      |      |    333. 00:00:00.01 |      57.      0 |      |      |          |

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - access("D".") "DAY_ID" ="F" DAY_ID')

    3 - access("P".") ' PRODUCT_ID ' =' F '" PRODUCT_ID')

    5 - filter("P".") PRODUCT_TYPE "=" TABLE")

    8 - inmemory (SYS_OP_BLOOM_FILTER (: BF0000, 'F'.)) ((' ' PRODUCT_ID '))

    filter (SYS_OP_BLOOM_FILTER (: BF0000, 'F'.)) ((' ' PRODUCT_ID '))

    9 - filter("D".") AN "= 2005)

    The massive difference in timing is almost entirely due to statistics_level = all.

    By operating without this parameter times were 1.58 and 1.23 seconds.

    I think the reason why there is not a lot of information on the Internet, it is that he is still relatively new and there are not many people who use it, and those who use it are so happy to improve they get that they are not checking to see if they get all the improvement that could be expected. and the people who tend to look at these things had much else to look at again. I spent a bit of time looking at HOW it works, but I didn't spend time looking for cases where the strategy is rejected, or the methods of costing.

    Concerning

    Jonathan Lewis

  • test DB has no AMM, the request takes 5 seconds, the prod DB has AMM query takes 5 minutes

    I created a copy of test of production for a long time, when I was creating the test I have not activated AMM.

    A developer created a new report and told me that it took seconds to run on the Pb test, as he was taking up to 10 minutes on the Pb of the production. I got it to extract the SQL code for the report and he ran from a command line, and on the Pb test, it took 5 seconds and more than 5 minutes on the Pb of the production.

    I then checked the AMM with the show memory_target parameter to see if AMM was activated and on the Pb of the prod is 1 GB on the DB test is 0

    memory allocation requests show this for prod:

    NAME                                     VALUE

    ------------------------------        ----------

    PGA maximum allowed 578929664

    pga_aggregate_target 0

    SGA_TARGET 0

    MEMORY_TARGET

    -------------

    578929664

    for the BP to test:

    NAME                                       VALUE

    ------------------------------          ----------

    PGA maximum allowed 214604800

    pga_aggregate_target 101711872

    SGA_TARGET 624951296

    MEMORY_TARGET

    -------------

    839556096

    I have not dbcontrol currently enabled on the Pb test, so I could not watch the advisors of the memory, but it is enabled on the Pb of the prod, that tells me it should be to the 1 GB is currently at.

    Two of these db are on the same server.

    Now I wonder if I should disable the AMM on the prod server and allocate manually to match the test, or should I change the AMM if possible so that it can perform as good as the Pb of test?

    Thanks in advance.

    I tried the suggestion of Geert earlier but I forgot to mention that it made no difference.

    However, I managed to find out what it is, starting at the beginning by looking at all the init parameters. It was then that I noticed the Prod OPTIMIZER_FEATURES_ENABLE was set to 9.2.0.8, while the test was 11.2.0.3, a quick alter system set optimizer_features_enable = '11.2.0.3' scope = both and the query ran<5 seconds,="" just="" like="" the="" test.="" it="" also="" got="" rid="" of="" the="" note="" that="" the="" cpu="" costing="" was="" not="">

    I thought a bit more wording accurate in the order note explain plan could be useful - but in any case, it makes sense, I guess...

    However, this has been a useful exercise for me, I have a better idea how they use the remote database for retrieving information and will make suggestions, it may be easier to create views of the side remote (SQL Server), rather than on the side of the Oracle.

    Still do not know how the test done with the right parameter and the prod has not, I used to create the init.ora file to create the test instance by getting a carbon copy of the production spfile, but I missed this setting this time.

    In any case, it's a good thing I had the right parameter under test - otherwise the Developer & users may have accepted, he was going to be a slow and left...

    Thanks again for all your help

    PS. Now here is the plan explain of production:

    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'ALLSTATS LAST'));
    SQL_ID  bqh1aq71rshpp, child number 1
    -------------------------------------
    SELECT /*+ GATHER_PLAN_STATISTICS */
    DOMCUST.CUSTOMER,DOMHEADER.WOODTYPE,DOMHEADER.ISSUEDATE ISSUEDATE,
    vw_testlots.TLOT_PREV PREV_LOT, VW_TESTLOTS.TLOT_NEXT NEXT_LOT,
    DOMLOTS.lotno ship_lot,       VW_PTMS_LOTS.AIRDRY
    AIRDRY,VW_PTMS_LOTS.BRIGHTNESS BRIGHT,VW_PTMS_LOTS.DIRT
    DIRT,VW_PTMS_LOTS.VISCOSITY VISCOSITY,
    (A.CCSF_0+B.CCSF_0)/2 CCSF_0,
    (A.TEAR1_0+B.TEAR1_0)/2 TEAR1_0,
    (A.BL_0+B.BL_0)/2 BL_0,
    (A.BURST_0+B.BURST_0)/2 BURST_0,
    (A.BULK_0+B.BULK_0)/2 BULK_0,
    (A.POROSITY_0+B.POROSITY_0)/2 POROSITY_0,
      (A.BOND_0+B.BOND_0)/2 BOND_0,
    (A.OPACITY_0+B.OPACITY_0)/2 OPACITY_0,
    (A.CCSF_1+B.CCSF_1)/2 CCSF_400,
    (A.TEAR1_1+B.TEAR1_1)/2 TEAR1_400,                                 (
    
    Plan hash value: 2207188603
    
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                              | Name         | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |  OMem |  1Mem | Used-Mem | Used-Tmp|
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                       |              |      1 |        |    255 |00:00:05.90 |    1091K|     45 |     45 |       |       |          |         |
    |   1 |  SORT AGGREGATE                        |              |    255 |      1 |    255 |00:00:00.91 |     385K|      0 |      0 |       |       |          |         |
    |*  2 |   FILTER                               |              |    255 |        |  57880 |00:00:01.11 |     385K|      0 |      0 |       |       |          |         |
    |*  3 |    TABLE ACCESS BY INDEX ROWID         | LOTTEST      |    255 |      1 |  57880 |00:00:00.99 |     385K|      0 |      0 |       |       |          |         |
    |*  4 |     INDEX RANGE SCAN                   | UK_LOTNO     |    255 |     45 |    767K|00:00:00.85 |    5015 |      0 |      0 |       |       |          |         |
    |   5 |  SORT AGGREGATE                        |              |    255 |      1 |    255 |00:00:00.52 |     158K|      0 |      0 |       |       |          |         |
    |*  6 |   FILTER                               |              |    255 |        |  55792 |00:00:00.47 |     158K|      0 |      0 |       |       |          |         |
    |*  7 |    TABLE ACCESS BY INDEX ROWID         | LOTTEST      |    255 |      1 |  55792 |00:00:00.36 |     158K|      0 |      0 |       |       |          |         |
    |*  8 |     INDEX RANGE SCAN                   | UK_LOTNO     |    255 |     45 |    516K|00:00:00.55 |    1372 |      0 |      0 |       |       |          |         |
    |   9 |  SORT ORDER BY                         |              |      1 |      1 |    255 |00:00:05.90 |    1091K|     45 |     45 | 70656 | 70656 |63488  (0)|         |
    |  10 |   NESTED LOOPS                         |              |      1 |        |    255 |00:00:04.47 |     547K|     45 |     45 |       |       |          |         |
    |  11 |    NESTED LOOPS                        |              |      1 |      1 |    255 |00:00:04.47 |     546K|     45 |     45 |       |       |          |         |
    |  12 |     NESTED LOOPS                       |              |      1 |      1 |    255 |00:00:03.88 |     383K|     45 |     45 |       |       |          |         |
    |  13 |      NESTED LOOPS                      |              |      1 |      1 |    255 |00:00:03.02 |     979 |     45 |     45 |       |       |          |         |
    |  14 |       NESTED LOOPS                     |              |      1 |      1 |    255 |00:00:03.01 |     712 |     45 |     45 |       |       |          |         |
    |* 15 |        HASH JOIN                       |              |      1 |      1 |    255 |00:00:03.01 |     527 |     45 |     45 |   858K|   858K| 1283K (0)|         |
    |  16 |         NESTED LOOPS                   |              |      1 |     19 |    255 |00:00:00.01 |      28 |      0 |      0 |       |       |          |         |
    |  17 |          NESTED LOOPS                  |              |      1 |      1 |      9 |00:00:00.01 |      17 |      0 |      0 |       |       |          |         |
    |  18 |           TABLE ACCESS BY INDEX ROWID  | DOMCUST      |      1 |      1 |      1 |00:00:00.01 |       2 |      0 |      0 |       |       |          |         |
    |* 19 |            INDEX UNIQUE SCAN           | PK_DOMCUST   |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |      0 |       |       |          |         |
    |* 20 |           TABLE ACCESS FULL            | DOMHEADER    |      1 |      1 |      9 |00:00:00.01 |      15 |      0 |      0 |       |       |          |         |
    |* 21 |          INDEX RANGE SCAN              | PK_DOMLOTS   |      9 |     21 |    255 |00:00:00.01 |      11 |      0 |      0 |       |       |          |         |
    |  22 |         VIEW                           | VW_PTMS_LOTS |      1 |    101 |  15101 |00:00:03.05 |     499 |     45 |     45 |       |       |          |         |
    |  23 |          SORT UNIQUE                   |              |      1 |    101 |  15101 |00:00:03.02 |     499 |     45 |     45 |  1328K|   587K| 1180K (0)|         |
    |  24 |           UNION-ALL                    |              |      1 |        |  15101 |00:00:03.06 |     499 |     45 |     45 |       |       |          |         |
    |  25 |            HASH GROUP BY               |              |      1 |    100 |  15101 |00:00:02.98 |       0 |     45 |     45 |  3004K|   982K| 3262K (1)|    1024 |
    |* 26 |             FILTER                     |              |      1 |    100 |  15842 |00:00:02.99 |       0 |      0 |      0 |       |       |          |         |
    |  27 |              REMOTE                    |              |      1 |        |  16563 |00:00:02.95 |       0 |      0 |      0 |       |       |          |         |
    |* 28 |            TABLE ACCESS FULL           | PTMSLOTS     |      1 |      1 |      0 |00:00:00.01 |     499 |      0 |      0 |       |       |          |         |
    |* 29 |        INDEX UNIQUE SCAN               | PK_DOMLOTS   |    255 |      1 |    255 |00:00:00.01 |     185 |      0 |      0 |       |       |          |         |
    |  30 |       TABLE ACCESS BY INDEX ROWID      | DOMHEADER    |    255 |      1 |    255 |00:00:00.01 |     267 |      0 |      0 |       |       |          |         |
    |* 31 |        INDEX UNIQUE SCAN               | PK_DOMHEADER |    255 |      1 |    255 |00:00:00.01 |      12 |      0 |      0 |       |       |          |         |
    |  32 |      TABLE ACCESS BY INDEX ROWID       | LOTTEST      |    255 |      1 |    255 |00:00:00.91 |     383K|      0 |      0 |       |       |          |         |
    |* 33 |       INDEX UNIQUE SCAN                | PK_LOTTEST   |    255 |      1 |    255 |00:00:00.91 |     382K|      0 |      0 |       |       |          |         |
    |  34 |        SORT AGGREGATE                  |              |    255 |      1 |    255 |00:00:00.91 |     382K|      0 |      0 |       |       |          |         |
    |  35 |         TABLE ACCESS BY INDEX ROWID    | LOTTEST      |    255 |      1 |    261 |00:00:00.90 |     382K|      0 |      0 |       |       |          |         |
    |* 36 |          INDEX RANGE SCAN              | UK_LOTNO     |    255 |      1 |    261 |00:00:00.90 |     382K|      0 |      0 |       |       |          |         |
    |  37 |           SORT AGGREGATE               |              |    255 |      1 |    255 |00:00:00.90 |     382K|      0 |      0 |       |       |          |         |
    |* 38 |            FILTER                      |              |    255 |        |  57880 |00:00:01.09 |     382K|      0 |      0 |       |       |          |         |
    |* 39 |             TABLE ACCESS BY INDEX ROWID| LOTTEST      |    255 |      1 |  57880 |00:00:00.97 |     382K|      0 |      0 |       |       |          |         |
    |* 40 |              INDEX RANGE SCAN          | UK_LOTNO     |    255 |     45 |    767K|00:00:00.85 |    1798 |      0 |      0 |       |       |          |         |
    |* 41 |     INDEX UNIQUE SCAN                  | PK_LOTTEST   |    255 |      1 |    255 |00:00:00.53 |     162K|      0 |      0 |       |       |          |         |
    |  42 |      SORT AGGREGATE                    |              |    255 |      1 |    255 |00:00:00.53 |     162K|      0 |      0 |       |       |          |         |
    |  43 |       TABLE ACCESS BY INDEX ROWID      | LOTTEST      |    255 |      1 |    264 |00:00:00.52 |     162K|      0 |      0 |       |       |          |         |
    |* 44 |        INDEX RANGE SCAN                | UK_LOTNO     |    255 |      1 |    264 |00:00:00.52 |     162K|      0 |      0 |       |       |          |         |
    |  45 |         SORT AGGREGATE                 |              |    255 |      1 |    255 |00:00:00.52 |     162K|      0 |      0 |       |       |          |         |
    |* 46 |          FILTER                        |              |    255 |        |  55792 |00:00:00.46 |     162K|      0 |      0 |       |       |          |         |
    |* 47 |           TABLE ACCESS BY INDEX ROWID  | LOTTEST      |    255 |      1 |  55792 |00:00:00.35 |     162K|      0 |      0 |       |       |          |         |
    |* 48 |            INDEX RANGE SCAN            | UK_LOTNO     |    255 |     45 |    516K|00:00:00.57 |    5282 |      0 |      0 |       |       |          |         |
    |  49 |    TABLE ACCESS BY INDEX ROWID         | LOTTEST      |    255 |      1 |    255 |00:00:00.01 |     255 |      0 |      0 |       |       |          |         |
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(:B1-365<=:B2+365)
       3 - filter(("WOODTYPE"=:B1 AND "PRODDATE">=:B2-365 AND "PRODDATE"<=:B3+365))
       4 - access("LOTNO"<:B1)
       6 - filter(:B1-365<=:B2+365)
       7 - filter(("WOODTYPE"=:B1 AND "PRODDATE">=:B2-365 AND "PRODDATE"<=:B3+365))
       8 - access("LOTNO">=:B1)
      15 - access("DOMLOTS"."LOTNO"="VW_PTMS_LOTS"."LOTID")
      19 - access("DOMCUST"."DOMCUSTID"=1)
      20 - filter(("DOMHEADER"."DOMCUSTID"=1 AND "DOMHEADER"."ISSUEDATE">=TO_DATE(' 2014-05-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "DOMHEADER"."WOODTYPE"='H'
                  AND TRUNC(INTERNAL_FUNCTION("DOMHEADER"."ISSUEDATE"))<=TO_DATE(' 2015-05-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss')))
      21 - access("DOMHEADER"."DOMID"="DOMLOTS"."DOMID")
      26 - filter("A"."StartTime">GREATEST(SYSDATE@!-730,TO_DATE(' 2013-04-16 13:00:00', 'syyyy-mm-dd hh24:mi:ss')))
      28 - filter("PRODTIME">SYSDATE@!-730)
      29 - access("DOMHEADER"."DOMID"="DOMLOTS"."DOMID" AND "DOMLOTS"."LOTNO"="DOMLOTS"."LOTNO")
      31 - access("DOMLOTS"."DOMID"="DOMHEADER"."DOMID")
      33 - access("A"."LOTID"=)
      36 - access("LOTTEST"."LOTNO"=)
      38 - filter(:B1-365<=:B2+365)
      39 - filter(("WOODTYPE"=:B1 AND "PRODDATE">=:B2-365 AND "PRODDATE"<=:B3+365))
      40 - access("LOTNO"<:B1)
      41 - access("B"."LOTID"=)
      44 - access("LOTTEST"."LOTNO"=)
      46 - filter(:B1-365<=:B2+365)
      47 - filter(("WOODTYPE"=:B1 AND "PRODDATE">=:B2-365 AND "PRODDATE"<=:B3+365))
      48 - access("LOTNO">=:B1)
    
    105 rows selected.
    
    Elapsed: 00:00:00.12
    
  • What is recursive query

    Hi gurus

    I'm trying to understand the concept of recursive queries, I tried to Google it but found not the details.

    I appreciate if someone tell me about recursive query and uses.

    Grateful if someone give me the example. Thank you

    Concerning

    Shu

    Here's a simple example. This query generates 10 rows with 1 column NWR.

    with t (NWR)

    as

    (

    Select 1 double NWR

    Union of all the

    Select rno + 1 NWR in t where rno + 1<=>

    )

    Select / * + gather_plan_statistics * / NWR

    t;

    Here SELECT it in red is called the anchor member. It is the starting point for your recursive with clause. SELECT it in Green called the recursive member. This is the part which refers to the query name (WITH clause) in the FROM clause. Where clause in the recursive member determines when must the recursive cycle.

    See the execution plan

    --------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Begins | E - lines. A - lines.   A - time |

    --------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |      1.        |     10. 00:00:00.01 |

    |   1.  VIEW                                     |      |      1.      2.     10. 00:00:00.01 |

    |   2.   UNION ALL (RECURSIVE WITH) WIDTH FIRST.      |      1.        |     10. 00:00:00.01 |

    |   3.    FAST DUAL                              |      |      1.      1.      1. 00:00:00.01 |

    |   4.    RECURSIVE WITH PUMP |      |     10.        |      9. 00:00:00.01 |

    --------------------------------------------------------------------------------------------------

    If you look at the lines A-implementation plan that you can see, the SELECTION anchor member generated 1 row and SELECT recursive member generated 9 rows.

    When the need for recursive cycle of BREAK is very important, if you do not specify Oracle triggers error.

    Like this

    with t (NWR)

    as

    (

    Select 1 double NWR

    Union of all the

    Select rno + 1 NWR in t

    )

    Select rno

    t;

    Here, I ignored where clause and returns to Oracle

    ORA-32044: cycle detected during execution of recursive WITH queries

  • Smart Scan does not

    Hello

    My version of the database is 11.2.0.3 64bits RAC environment running on quarter basket exadata. When I ran the SQL below, the plan that got generated showed STORAGE INDEX FAST FULL SCAN also indicated below.

    select /*+ GATHER_PLAN_STATISTICS*/ count(*) from jarosods.GL_IMPORTREFERENCES_DET a the actual execution is as below
    

    Hello

    Diluvium readings are eligible for SmartScan only if it is made in direct-path. You don't need to change the DOP, since she can use the direct path read series (according to the size of the segment, how many blocks is in the cache, and how many of them is dirty - see https://fritshoogland.wordpress.com/2013/05/09/direct-path-read-and-fast-full-index-scans/). Even with higer DOP, parallel query may choose to use the cache buffers - so not SmartScan.

    Kind regards

    Franck.

  • Help setting up a SQL query with poor performance

    Hi all

    Database version: 10.2.0.5

    I'm working on a new report to view the top users by the number of calls. The table is truncated and filled again every month with records for the previous month; It contains approximately 400 000 records.

    I created a view with the columns needed for the report; also, the two functions of view calls to determine if a phone number is assigned to multiple staffs or several departments.

    It's full again table every month:

     CREATE TABLE "VOIP"."MONTHLY_BILLING_DETAILS" 
       (    "ID" NUMBER NOT NULL ENABLE, 
        "CDRRECORDTYPE" NUMBER, 
        "G_CALLMANAGERID" NUMBER, 
        "G_CALLID" NUMBER, 
        "O_LEGCALLIDENTIFIER" NUMBER, 
        "DATETIMEORIGINATION" NUMBER, 
        "O_NODEID" NUMBER, 
        "O_SPAN" NUMBER, 
        "O_IPADDR" NUMBER, 
        "CALLINGPARTYNUMBER" VARCHAR2(50 BYTE) NOT NULL ENABLE, 
        "CALLINGPARTY_USERID" VARCHAR2(128 BYTE), 
        "O_CAUSE_LOCATION" NUMBER, 
        "O_CAUSE_VALUE" NUMBER, 
        "O_PRECEDENCELEVEL" NUMBER, 
        "O_MEDIATRANSPORTADDR_IP" NUMBER, 
        "O_MEDIATRANSPORTADDR_PORT" NUMBER, 
        "O_MCAP_PAYLOADCAPABILITY" NUMBER, 
        "O_MCAP_MAXFRAMESPERPACKET" NUMBER, 
        "O_MCAP_G723BITRATE" NUMBER, 
        "O_VCAP_CODEC" NUMBER, 
        "O_VCAP_BANDWIDTH" NUMBER, 
        "O_VCAP_RESOLUTION" NUMBER, 
        "O_VIDEOTRANSPORTADDR_IP" NUMBER, 
        "O_VIDEOTRANSPORTADDR_PORT" NUMBER, 
        "O_RSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "O_RSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DESTLEGIDENTIFIER" NUMBER, 
        "DESTNODEID" NUMBER, 
        "DESTSPAN" NUMBER, 
        "DESTIPADDR" NUMBER, 
        "ORIGINALCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTY_USERID" VARCHAR2(128 BYTE), 
        "DESTCAUSE_LOCATION" NUMBER, 
        "DESTCAUSE_VALUE" NUMBER, 
        "DESTPRECEDENCELEVEL" NUMBER, 
        "DESTMEDIATRANSPORTADDR_IP" NUMBER, 
        "DESTMEDIATRANSPORTADDR_PORT" NUMBER, 
        "DESTMCAP_PAYLOADCAPABILITY" NUMBER, 
        "DESTMCAP_MAXFRAMESPERPACKET" NUMBER, 
        "DESTMCAP_G723BITRATE" NUMBER, 
        "DV_CAP_CODEC" NUMBER, 
        "DV_CAP_BANDWIDTH" NUMBER, 
        "DV_CAP_RESOLUTION" NUMBER, 
        "DV_TRANSPORTADDR_IP" NUMBER, 
        "DV_TRANSPORTADDR_PORT" NUMBER, 
        "DESTRSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "DESTRSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DATETIMECONNECT" NUMBER, 
        "DATETIMEDISCONNECT" NUMBER, 
        "LASTREDIRECTDN" VARCHAR2(50 BYTE), 
        "PKID" VARCHAR2(4000 BYTE), 
        "O_INALCALLEDPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "CALLINGPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "LASTREDIRECTDNPARTITION" VARCHAR2(50 BYTE), 
        "DURATION" NUMBER, 
        "O_DEVICENAME" VARCHAR2(129 BYTE), 
        "DESTDEVICENAME" VARCHAR2(129 BYTE), 
        "O_CALLTERMINATION_BEHALF" NUMBER, 
        "DESTCALLTERMINATION_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECT_BEHALF" NUMBER, 
        "LASTREDIRECTREDIRECT_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECTREASON" NUMBER, 
        "LASTREDIRECTREDIRECTREASON" NUMBER, 
        "DESTCONVERSATIONID" NUMBER, 
        "G_CALLID_CLUSTERID" VARCHAR2(50 BYTE), 
        "JOIN_BEHALF" NUMBER, 
        "COMMENTS" VARCHAR2(2048 BYTE), 
        "AUTHCODEDESCRIPTION" VARCHAR2(50 BYTE), 
        "AUTHORIZATIONLEVEL" NUMBER, 
        "CLIENTMATTERCODE" VARCHAR2(32 BYTE), 
        "O_DTMFMETHOD" NUMBER, 
        "DESTDTMFMETHOD" NUMBER, 
        "CALLSECUREDSTATUS" NUMBER, 
        "O_CONVERSATIONID" NUMBER, 
        "O_MCAP_BANDWIDTH" NUMBER, 
        "DESTMCAP_BANDWIDTH" NUMBER, 
        "AUTHORIZATIONCODEVALUE" VARCHAR2(32 BYTE), 
        "OUTPULSEDCALLINGPARTYNUMBER" VARCHAR2(50 BYTE), 
        "OUTPULSEDCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "O_IPV4V6ADDR" VARCHAR2(64 BYTE), 
        "DESTIPV4V6ADDR" VARCHAR2(64 BYTE), 
        "O_VCAP_CODEC_CHAN2" NUMBER, 
        "O_VCAP_BANDWIDTH_CHAN2" NUMBER, 
        "O_VCAP_RESOLUTION_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "O_V_OCHANNEL_ROLE_CHAN2" NUMBER, 
        "DV_CAP_CODEC_CHAN2" NUMBER, 
        "DV_CAP_BANDWIDTH_CHAN2" NUMBER, 
        "DV_CAP_RESOLUTION_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "DV_CHANNEL_ROLE_CHAN2" NUMBER, 
        "DATE_CREATED" DATE, 
        "DATETIME_CONNECT" DATE, 
        "DATETIME_DISCONNECT" DATE, 
        "USERID_EMAIL_ADDRESS" VARCHAR2(100 BYTE), 
        "FROM_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "TO_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "FROM_EXCHANGE" VARCHAR2(7 BYTE), 
        "TO_EXCHANGE" VARCHAR2(20 BYTE), 
        "FROM_CITY" VARCHAR2(200 BYTE), 
        "FROM_STATE" VARCHAR2(2 BYTE), 
        "TO_CITY" VARCHAR2(200 BYTE), 
        "TO_STATE" VARCHAR2(2 BYTE), 
        "CALL_TYPE" VARCHAR2(10 BYTE), 
         CONSTRAINT "MONTHLY_BILLING_PK" PRIMARY KEY ("ID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 75497472 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX1" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX10" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("CALL_TYPE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX2" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX3" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_FULL_TELEPHONE", TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX4" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX5" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("TO_FULL_TELEPHONE","ORIGINALCALLEDPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX6" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TO_CHAR("DATETIME_CONNECT",'fmMONTH YYYY')) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX7" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("TO_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX8" ON "VOIP"."MONTHLY_BILLING_DETAILS" (NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX9" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    

    These are the functions to determine if a phone number is assigned to multiple staffs or departments:

    FUNCTION GET_EMPLOYEE_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_NAME EMPLOYEES.NAME%TYPE;
    BEGIN
      SELECT NAME
      INTO L_NAME
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_NAME;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_NAME := 'Multiple Employees';
        RETURN L_NAME;
      WHEN NO_DATA_FOUND THEN
        L_NAME := 'No Employee Assigned';
        RETURN L_NAME;
      WHEN OTHERS THEN
        NULL;
    END;
    

    FUNCTION GET_DEPARTMENT_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_DEPT_DESCR EMPLOYEES.DEPT_DESCR%TYPE;
    BEGIN
      SELECT DEPT_DESCR
      INTO L_DEPT_DESCR
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_DEPT_DESCR;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_DEPT_DESCR := 'Multiple Departments';
        RETURN L_DEPT_DESCR;
      WHEN NO_DATA_FOUND THEN
        L_DEPT_DESCR := 'No Department Assigned';
        RETURN L_DEPT_DESCR;
      WHEN OTHERS THEN
        NULL;
    END;
    

    This is the point of view that I'll use in the report:

    CREATE OR REPLACE FORCE VIEW "VOIP"."TOP_USERS_BY_CALLS_V" ("TOP_NO", "EMPLOYEE_NAME", "EMPLOYEE_DEPARTMENT", "PHONE_NUMBER", "QUANTITY_CALLS") AS 
      SELECT
      ROWNUM,
      VOIP_PKG.GET_EMPLOYEE_NAME(FROM_FULL_TELEPHONE),
      VOIP_PKG.GET_DEPARTMENT_NAME(FROM_FULL_TELEPHONE),
      FROM_FULL_TELEPHONE,
      QUANTITY_CALLS
    FROM (
    SELECT
      MBD.FROM_FULL_TELEPHONE,
      COUNT(1) QUANTITY_CALLS
    FROM
      MONTHLY_BILLING_DETAILS MBD
    WHERE
      MBD.FROM_FULL_TELEPHONE IS NOT NULL                                     AND
      MBD.FROM_FULL_TELEPHONE <> '000-000-0000'                               AND
      LENGTH(MBD.FROM_FULL_TELEPHONE) = 12                                    AND
      LENGTH(MBD.TO_FULL_TELEPHONE) = 12                                      AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN (SELECT AREA_CODE
                                                FROM NYNJ_METRO_AREA_CODES)   AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN ('800','822','833','844',
                                                '855','866','877','888')
    GROUP BY
      MBD.FROM_FULL_TELEPHONE
    ORDER BY
      QUANTITY_CALLS DESC
    )
    WHERE ROWNUM <= 100;
    

    Explain Plan output and Extended SQL Trace:


    SQL> 
    SQL> show parameter user_dump_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    user_dump_dest                       string      D:\ORACLEHOMES\ADMIN\RTS9\UDUM
                                                     P
    SQL> 
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.5
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     16
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select
      2  sname
      3  , pname
      4  , pval1
      5  , pval2
      6  from
      7  sys.aux_stats$;
    
    SNAME                PNAME                     PVAL1 PVAL2
    -------------------- -------------------- ---------- --------------------
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          02-09-2009 15:46
    SYSSTATS_INFO        DSTOP                           02-09-2009 15:46
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW            1259.6206
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> 
    SQL> explain plan for
      2  SELECT
      3    TOP_NO,
      4    EMPLOYEE_NAME,
      5    EMPLOYEE_DEPARTMENT,
      6    PHONE_NUMBER,
      7    QUANTITY_CALLS
      8  FROM
      9    TOP_USERS_BY_CALLS_V
     10  ORDER BY
     11    QUANTITY_CALLS DESC;
    
    Explained.
    
    Elapsed: 00:00:00.18
    SQL> 
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    33 rows selected.
    
    Elapsed: 00:00:00.82
    SQL> 
    SQL> rollback;
    
    Rollback complete.
    
    Elapsed: 00:00:00.00
    SQL> 
    SQL> set autotrace traceonly arraysize 100
    SQL> 
    SQL> alter session set tracefile_identifier = 'mytrace1';
    
    Session altered.
    
    Elapsed: 00:00:00.01
    SQL> 
    SQL> alter session set events '10046 trace name context forever, level 8';
    
    Session altered.
    
    Elapsed: 00:00:00.15
    SQL> 
    SQL> SELECT
      2    TOP_NO,
      3    EMPLOYEE_NAME,
      4    EMPLOYEE_DEPARTMENT,
      5    PHONE_NUMBER,
      6    QUANTITY_CALLS
      7  FROM
      8    TOP_USERS_BY_CALLS_V
      9  ORDER BY
     10    QUANTITY_CALLS DESC;
    
    100 rows selected.
    
    Elapsed: 00:10:37.68
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    Statistics
    ----------------------------------------------------------
            365  recursive calls
              0  db block gets
         689543  consistent gets
         212906  physical reads
              0  redo size
           5984  bytes sent via SQL*Net to client
            400  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
            100  rows processed
    
    SQL> 
    SQL> disconnect
    

    Part of the automatic trace output:

    SELECT
      TOP_NO,
      EMPLOYEE_NAME,
      EMPLOYEE_DEPARTMENT,
      PHONE_NUMBER,
      QUANTITY_CALLS
    FROM
      TOP_USERS_BY_CALLS_V
    ORDER BY
      QUANTITY_CALLS DESC
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.43          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     24.70     635.81     212587     631823          0         100
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     24.70     636.25     212587     631823          0         100
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 148  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
        100  SORT ORDER BY (cr=689531 pr=212900 pw=0 time=636823070 us)
        100   VIEW  TOP_USERS_BY_CALLS_V (cr=689531 pr=212900 pw=0 time=642681672 us)
        100    COUNT STOPKEY (cr=631823 pr=212587 pw=0 time=635667026 us)
        100     VIEW  (cr=631823 pr=212587 pw=0 time=635666810 us)
        100      SORT ORDER BY STOPKEY (cr=631823 pr=212587 pw=0 time=635666493 us)
       2512       HASH GROUP BY (cr=631823 pr=212587 pw=0 time=635666125 us)
      27112        FILTER  (cr=631823 pr=212587 pw=0 time=519230237 us)
     315563         TABLE ACCESS BY INDEX ROWID MONTHLY_BILLING_DETAILS (cr=381523 pr=212587 pw=0 time=580209555 us)
     394473          INDEX FULL SCAN MONTHLY_BILL_INDEX3 (cr=2679 pr=2679 pw=0 time=26793918 us)(object id 206675)
     226627         INDEX FULL SCAN NYNJ_METRO_AREA_CODES_UK1 (cr=250300 pr=0 pw=0 time=3575488 us)(object id 206605)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      db file sequential read                    212587        0.20        611.67
      SQL*Net message from client                     2        0.00          0.00
      SQL*Net more data to client                     2        0.00          0.00
    ********************************************************************************
    

    DBMS_XPLAN. Output DISPLAY_CURSOR:

    SQL> 
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  1ut636vt58jdw, child number 0
    -------------------------------------
    SELECT /*+ gather_plan_statistics */   TOP_NO,   EMPLOYEE_NAME,   EMPLOYEE_DEPARTMENT,   PHONE_NUMBER,   QUANTITY_CALLS FROM   TOP_USERS_BY_CALLS_V
    ORDER BY   QUANTITY_CALLS DESC
    
    Plan hash value: 826236322
    
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |      1 |        |    100 |00:09:56.06 |     689K|    210K|       |       |          |
    |   1 |  SORT ORDER BY                     |                           |      1 |      1 |    100 |00:09:56.06 |     689K|    210K| 13312 | 13312 |12288  (0)|
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |      1 |      1 |    100 |00:10:04.98 |     689K|    210K|       |       |          |
    |*  3 |    COUNT STOPKEY                   |                           |      1 |        |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |   4 |     VIEW                           |                           |      1 |      1 |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |      1 |      1 |    100 |00:09:54.88 |     631K|    210K|  6144 |  6144 | 6144  (0)|
    |   6 |       HASH GROUP BY                |                           |      1 |      1 |   2512 |00:09:54.88 |     631K|    210K|   821K|   821K| 1153K (0)|
    |*  7 |        FILTER                      |                           |      1 |        |  27112 |00:08:58.57 |     631K|    210K|       |       |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |      1 |      1 |    315K|00:08:57.07 |     381K|    210K|       |       |          |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |      1 |    934 |    394K|00:00:23.02 |    2679 |   2679 |       |       |          |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |    250K|      1 |    226K|00:00:03.47 |     250K|      0 |       |       |          |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( IS NULL)
       8 - filter((LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888'))
       9 - filter((LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000' AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL))
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    35 rows selected.
    
    Elapsed: 00:00:00.50
    SQL> 
    SQL> spool off
    
    

    Any help will be greatly appreciated. Please let me know if you need additional information.

    Thank you

    Erick

    ediazjorge wrote:

    Please let me know if you need additional information or do additional tests.

    Thanks again!

    Erick

    It's to you if you are satisfied or interested in improvements (if possible).

    If so the first thing I would like if you had your refreshed perspective as advised. According to expected area_code table cardinalities I doubt.

    So, if not cool off with dbms_stats.gather_table_stats on two tables, area_codes and MONTHLY_BILLING_DETAILS.

    Bottlenecks are now obviously the full table of MONTHLY_BILLING_DETAILS as well as the ANTI of LOOPS IMBRIQUEES scan.

    At the moment I don't think that an index of MONTHLY_BILLING_DETAILS will help a lot, because most of the lines will pass filter predicates, and because we need some columns in it, I have now I there will be gain a full index scan.

    I was surprissed that the optimizer pushes the substr <> predicates to both tables.

    So depending on your data, you might try

    1 make a factory of subquery select the two MONTHLY_BILLING_DETAILS columns that all directly apply predicates of membership and use it directly in the join instead of the table.

    or

    2. If all subtr to so are part of the table area_code choose in it using a subquery (or inline view) plant excluding these values.

    Both are attempts to get rid of the substr excluding as filters of join predicates.

    In fact, I was expecting a hash join anti as shown in the plan to explain instead of the nested loops anti, I expect to be more effective in this case.

    Perhaps with correct cardinalities the optimizier would understand himself.

    Just to test it, you can try the use_hash hint in the join:

    Select / * + USE_HASH (MBD, one) * /.

    ..

    OF MONTHLY_BILLING_DETAILS MBD,.

    NYNJ_METRO_AREA_CODES one

    (It's a good habit anyway usually use aliases and precede the names of columns. In the, it is easier to read queries are only trivial).

  • Query statistics get error

    Hello

    I try to get a query such as statistic: select / * + gather_plan_statistics * / s.req_id, s.unit_program_name... bla...

    Next: select * from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));

    I get this message:

    1 9m7787camwh4m SQL_ID, number of children 0

    2

    3. start: id: = sys.dbms_transaction.local_transaction_id; end;

    4

    NOTE 5: impossible to extract plan for SQL_ID: 9m7787camwh4m, CHILD_NUMBER: 0

    6. check the value of SQL_ID and CHILD_NUMBER;

    7 it could also be that the plan is no longer in the cursor cache (check v$ sql_plan)

    8

    Any ideas on this problem?

    Thank you

    Hello...

    Select * from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));

    --> first parameter null

    By default, the table DISPLAY_CURSOR function formats the execution plan of the last SQL statement executed by the sessions

    See doc.

    https://docs.Oracle.com/CD/B19306_01/AppDev.102/b14258/d_xplan.htm#i999234

    Try to get the SQL_ID based on the SQL TEXT and try to get this specific slider!

    Select sql_id, sql_text from V$ sql where sql_text like '% of the TEXT. "

    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (('', 0, 'ALLSTATS DERNIÈRE'));

    Also posted a comment on below on "DBMS_XPLAN. DISPLAY_CURSOR ".

    https://community.Oracle.com/thread/3636820

  • Insert in varchar2 select xmltype column: extremely slow

    I use oracle10gR2 10.2.0.4 and solaris10 64bits

    I need to select the data to an xml value in a table of column xmltype (word.testmeta)

    and insert into another table (word.testwordyy)

    desc word.testmeta;
    Name                 Null?    Type
    --------------------------------------
    FILENAME             CHAR(2000)
    XMLDATA              XMLTYPE
    
    
    desc word.testwordyy;
    Name                 Null?    Type
    ---------------------------------------
    ID                   VARCHAR2(255)
    KEYWORD              VARCHAR2(4000)
    

    and I use xmltable

    insert /*+append */ into word.testwordyy(KEYWORD)
    select /*+ gather_plan_statistics */ dbms_lob.substr(xmltype.getclobval(b.KEWOR),254)
    from word.testmeta , xmltable
    (
    '$B/mets/KEWOR'
    passing
    word.testmeta.XMLDATA as B
    columns
    KEWOR xmltype path '/KEWOR/text()'
    )
    b
    

    > select * from table(dbms_xplan.display_cursor(null,null,'iostats last')); 
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  37ua3npnxx8su, child number 0
    -------------------------------------
    insert /*+append */ into word.testwordyy(KEYWORD) select /*+ gather_plan_statistics */
    dbms_lob.substr(xmltype.getclobval(b.KEWOR),254) from word.testmeta , xmltable ( '$B/mets/KEWOR' passing word.testmeta.XMLDATA as
    B columns KEWOR xmltype path '/KEWOR/text()' ) b
    
    
    Plan hash value: 875848213
    
    
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                           | Name                   | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |
    
    
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    |   1 |  LOAD AS SELECT                     |                        |      1 |        |      1 |00:10:32.72 |   16832 |      7 |   90 |
    
    
    |   2 |   NESTED LOOPS                      |                        |      1 |     29M|  34688 |00:00:25.95 |   12639 |      5 |    0 |
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    |   3 |    TABLE ACCESS FULL                | TESTMETA               |      1 |   3638 |   3999 |00:00:00.08 |     909 |      0 |    0 |
    
    
    |   4 |    COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE |   3999 |        |  34688 |00:00:24.50 |   11730 |      5 |    0 |
    
    
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------
    Note
    -----
       - dynamic sampling used for this statement
    
    
    
    
    21 rows selected.
    

    and the more the number of rows in the word.testmeta table, the more time spent by rank

    I have a small simple XML but I need to process a large amount of them (5000000) as well as the treatment is very very slow when the lines of more than 8000

    Is there an optimization or the fastest?

    Why? Because you do a manipulation of LOB lob.

    Your XMLType is the kind of CLOB storage

    Your chain of subtr quantities are manipulationg LOB

    Altogether, the XML must be done in memory (XMLSEQUENCEFROMXMLTYPE), the manipulation of strings (CLOB) become bigger and bigger and bigger and will eat all your memory and CPU resources.

    How to solve it?

    Upgrade to a supported database version (11.2.0.3 and upwards)

    Store XML documents in a binary XML format of XMLType Securefile

    Use simple methods like XMLCAST to make the string conversion and manipulation

    Or...

    .. m:System.NET.HttpListener.start reading by doing the hard (and today with a version of database not supported), 10.2 through storage XMLType object / relational and convert you CLOB, XMLType storage for storing XMLType object / relational. Use the functions and operators that are created to make the manipulation of strings instead of DBMS_LOB Package (which is not free memory automatically)

  • Question of enforcement

    Hi all

    I'm trying to get the execution plan for a query from command line like:

    Set SERVEROUTPUT OFF;

    ALTER session set statistics_level = "ALL";

    SELECT / * + gather_plan_statistics * / fieldA, fieldB from myTable;

    Select * from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));

    I already add privileges to my user using the connection of the SYS user as:

    Grant SELECT ON V_$ SESSION TO myUser

    Grant SELECT ON V_$ SQL TO myUser

    Grant SELECT ON V_$ SQL_PLAN TO myUser

    Grant SELECT ON V_$ SQL_PLAN_STATISTICS_ALL TO myUser


    I get this error:

    SQL_ID  8kfd4vsgdvxuh, child number 0 
                                          
     declare     l_line varchar2(32767);     l_done number;     l_buffer
    varchar2(32767) := '';     l_lengthbuffer number := 0;     l_lengthline
    number := 0; begin   loop    dbms_output.get_line( l_line, l_done );
    if (l_buffer is null) then      l_lengthbuffer := 0;    else
    l_lengthbuffer := length(l_buffer);    end if;    if (l_line is null)
    then      l_lengthline := 0;    else      l_lengthline :=         
    length(l_line);    end if;   exit when l_lengthbuffer + l_lengthline >
    :maxbytes OR l_lengthbuffer + l_lengthline > 32767 OR l_done = 1;
    l_buffer := l_buffer || l_line || chr(10);      end loop;      :done :=
    l_done;      :buffer := l_buffer;      :line := l_line;  end;
    
    NOTE: cannot fetch plan for SQL_ID: 8kfd4vsgdvxuh, CHILD_NUMBER: 0
          Please verify value of SQL_ID and CHILD_NUMBER;         
          It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    

    Can anyone help?

    Thank you!

    NOTE: The use of Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0

    the plan seems more plausible than before: the expensive NL with 2 M iterations join disappeared and although the CBO used some misleading cardinalities I don't think that these errors have a decisive impact on the plan: the engine must build big enough intermediate results (1527K lines) which are grouped towards the end of the execution (BY GROUP of HASH in step 2). Perhaps you could improve the performance of reunification at an earlier stage (maybe the intermediate joints produce same duplicates) - but to answer this question an intensive analysis of the logic of the query would be necessary.

Maybe you are looking for

  • iTunes Setup error message

    Trying to install the latest version of iTunes on window 10 (but had this error in Windows 7, too): Error message: "There is a problem with this installation package. A program required for installation to complete could not be run. Contact your pers

  • HP Pavilion Elite m951of: update the BIOS

    My computer BIOS is American Megatrends, Inc. 5.35 12/16/08. I want to run a program that requires a virtual machine. It seems that my BIOS is virtualization support nt. It seems that my BIOS may not be updated to support virtualization. My understan

  • HP ENVY 7640: HP Pavilion will connect is more HP ENVY 7640

    Our Pavilion laptop worked perfectly with our HP ENVY 7640 until a few days ago.  I tried troubleshooting, reload the drivers, nothing seems to work.  When to screen printing, he constantly says "connecting" but nothing happens.  Any suggestions?

  • What is Mr. Fixit?

    Whatever it is, it does not work.

  • Error code 646 Microsoft Works 9 (2092914 KB)

    Hello. I tried to install this update (KB2092914) and it gave me an error code 646. What can I do? Only moderators answer please. Here are the details of the update: Update of security for Microsoft Works 9 (KB2092914) Download size: 2.0 MB You may h