Path to XML index table is full table scan

Hi all

I have a version of oracle 11.2.0.4.6 database

Try to implement partitioning on XML indexes.

Creates a table and index partitioned by time stamp as below.

Whenever I'm trying to find the path table makes a full table scan.

I have applied the fix as indicated ( Doc ID 13522189.8 ).

So the recovery is quite slow and partition pruning does not not on XML indexes.

Wondering if anyone has experienced the same problem?

CREATE TABLE INCIDENT

(

INCIDENT_PK NUMBER (14.5).

INCIDENTGROUPING_PK NUMBER (14.5).

INCIDENTTYPE_PK NUMBER (14.5).

SECURITYCLASS_PK NUMBER (14.5).

STAMP OF INCIDENT_DATE,

SYS INCIDENT_DETAIL. XMLTYPE

)

TABLESPACE DATA_TBS_INCIDENT

PCTUSED 0

PCTFREE 10

INITRANS 1

MAXTRANS 255

STORAGE)

64K INITIALS

MINEXTENTS 1

MAXEXTENTS UNLIMITED

PCTINCREASE 0

DEFAULT USER_TABLES

)

LOGGING

NOCOMPRESS

PARTITION BY RANGE (INCIDENT_DATE)

(PARTITION SEP2013_WEEK1 VALUES LESS THAN (to_timestamp (' 00:00:00.00 2013-09-08 ',' YYYY-MM-DD HH24:MI:SS.))) FF2')),

PARTITION SEP2013_WEEK2 VALUES LESS THAN (to_timestamp ('2013-09-15 00:00:00.00 ',' YYYY-MM-DD HH24:MI:SS.)) FF2')),

PARTITION SEP2013_WEEK3 VALUES LESS THAN (to_timestamp ('2013-09-22 00:00:00.00 ',' YYYY-MM-DD HH24:MI:SS.)) FF2')),

..........);

CREATE the INDEX INCIDENTxdb_idx

ON corpaudlive. INCIDENT (INCIDENT_detail) INDEXTYPE IS XDB. LOCAL XMLINDEX 10 PARALLEL

PARAMETERS (' PATH TABLE INCIDENT_PATHTABLE (TABLESPACE DATA_TBS_INCIDENT))

PIKEY INDEX INCIDENT_PATHTABLE_PIKEY_IX (TABLESPACE IDX_TBS_INCIDENT)

PATH ID INDEX INCIDENT_PATHTABLE_ID_IX (TABLESPACE IDX_TBS_INCIDENT)

INCIDENT_PATHTABLE_VALUE_IX VALUE INDEX (TABLESPACE IDX_TBS_INCIDENT)

ORDER KEY INDEX INCIDENT_PATHTABLE_KEY_IX (TABLESPACE IDX_TBS_INCIDENT)

Paths (INCLUDE (//forename //surname //postcode //dateofbirth //street //town))');

SQL > explain the plan for

2 Select INCIDENT_pk in INCIDENT where XMLEXISTS ('/ / name [text () = 'john']' by the way of INCIDENT_detail)

3 and XMLEXISTS ("/ / name [text () 'clark' =]' by the way of INCIDENT_detail")

4 and a.INCIDENT_date between TO_TIMESTAMP (January 10, 2014 ',' DD/MM/YYYY "")

5 and TO_TIMESTAMP (September 10, 2014 ',' DD/MM/YYYY ');

He explained.

Elapsed time: 00:00:02.77

SQL > select * from table (dbms_xplan.display);

PLAN_TABLE_OUTPUT

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

Hash value of plan: 123057549

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

| ID | Operation                                       | Name                           | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |    TQ | IN-OUT | PQ Distrib.

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

|   0 | SELECT STATEMENT |                                |     1.    70.  1803 (5) | 00:00:22 |       |       |        |      |            |

|   1.  COORDINATOR OF PX |                                |       |       |            |          |       |       |        |      |            |

|   2.   PX SEND QC (RANDOM). : TQ10003 |     1.    70.  1803 (5) | 00:00:22 |       |       |  Q1, 03 | P > S | QC (RAND) |

|   3.    SEMI NESTED LOOPS.                                |     1.    70.  1803 (5) | 00:00:22 |       |       |  Q1, 03 | SVCP |            |

|   4.     NESTED LOOPS |                                |     1.    57.  1800 (5) | 00:00:22 |       |       |  Q1, 03 | SVCP |            |

|   5.      VIEW                                       | VW_SQ_1                        |   239.  5975 |  1773 (5) | 00:00:22 |       |       |  Q1, 03 | SVCP |            |

PLAN_TABLE_OUTPUT

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

|   6.       UNIQUE HASH |                                |   239. 25334 |            |          |       |       |  Q1, 03 | SVCP |            |

|   7.        RECEIVE PX |                                |   239. 25334 |            |          |       |       |  Q1, 03 | SVCP |            |

|   8.         PX SEND HASH | : TQ10002 |   239. 25334 |            |          |       |       |  Q1, 02 | P > P | HASH |

|   9.          UNIQUE HASH |                                |   239. 25334 |            |          |       |       |  Q1, 02 | SVCP |            |

| * 10 |           HASH JOIN |                                |   239. 25334 |  1773 (5) | 00:00:22 |       |       |  Q1, 02 | SVCP |            |

|  11.            KIND OF BUFFER.                                |       |       |            |          |       |       |  Q1, 02 | ISSUE |            |

|  12.             RECEIVE PX |                                |     1.    22.     3 (0) | 00:00:01 |       |       |  Q1, 02 | SVCP |            |

|  13.              PX SEND BROADCAST | : TQ10000 |     1.    22.     3 (0) | 00:00:01 |       |       |        | S > P | BROADCAST |

|  14.               TABLE ACCESS BY INDEX ROWID | X$ PT74MSS0WBH028JE0GUCLBK0LHM4 |     1.    22.     3 (0) | 00:00:01 |       |       |        |      |            |

| * 15 |                INDEX RANGE SCAN | X$ PR74MSS0WBH028JE0GUCLBK0LHM4 |     1.       |     2 (0) | 00:00:01 |       |       |        |      |            |

| * 16.            HASH JOIN |                                | 12077 |   990K |  1770 (5) | 00:00:22 |       |       |  Q1, 02 | SVCP |            |

PLAN_TABLE_OUTPUT

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

|  17.             RECEIVE PX |                                |   250K |    10 M |    39 (0) | 00:00:01 |       |       |  Q1, 02 | SVCP |            |

|  18.              PX SEND BROADCAST | : TQ10001 |   250K |    10 M |    39 (0) | 00:00:01 |       |       |  Q1, 01 | P > P | BROADCAST |

|  19.               SYSTEM PARTITION ALL |                                |   250K |    10 M |    39 (0) | 00:00:01 |     1.   112.  Q1, 01 | ISSUE |            |

| * 20.                TABLE ACCESS BY LOCAL INDEX ROWID | INCIDENT_PATHTABLE |   250K |    10 M |    39 (0) | 00:00:01 |     1.   112.  Q1, 01 | SVCP |            |

| * 21.                 INDEX RANGE SCAN | INCIDENT_PATHTABLE_VALUE_IX |   161.       |    25 (0) | 00:00:01 |     1.   112.  Q1, 01 | SVCP |            |

|  22.             ITERATOR BLOCK PX |                                |   221 M |  8865M |  1671 (1) | 00:00:21 |    53.    54.  Q1, 02 | ISSUE |            |

| * 23.              TABLE ACCESS FULL | INCIDENT_PATHTABLE |   221 M |  8865M |  1671 (1) | 00:00:21 |    53.    54.  Q1, 02 | SVCP |            |

| * 24.      TABLE ACCESS BY ROWID USER | INCIDENT |     1.    32.     1 (0) | 00:00:01 | ROWID | ROWID |  Q1, 03 | SVCP |            |

| * 25.     SEE PUSHED PREDICATE. VW_SQ_2                        |     1.    13.    20 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

|  26.      NESTED LOOPS |                                |     1.   106.    20 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

|  27.       NESTED LOOPS |                                |     4.   106.    20 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

PLAN_TABLE_OUTPUT

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

|  28.        NESTED LOOPS |                                |     4.   256.     8 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

|  29.         TABLE ACCESS BY INDEX ROWID | X$ PT74MSS0WBH028JE0GUCLBK0LHM4 |     1.    22.     3 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

| * 30 |          INDEX RANGE SCAN | X$ PR74MSS0WBH028JE0GUCLBK0LHM4 |     1.       |     2 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

|  31.         ITERATOR SYSTEM PARTITION.                                |     4.   168.     5 (0) | 00:00:01 |    53.    54.  Q1, 03 | SVCP |            |

| * 32 |          TABLE ACCESS BY LOCAL INDEX ROWID | INCIDENT_PATHTABLE |     4.   168.     5 (0) | 00:00:01 |    53.    54.  Q1, 03 | SVCP |            |

| * 33 |           INDEX RANGE SCAN | INCIDENT_PATHTABLE_PIKEY_IX |     4.       |     4 (0) | 00:00:01 |    53.    54.  Q1, 03 | SVCP |            |

|  34.        ITERATOR SYSTEM PARTITION.                                |     1.       |     2 (0) | 00:00:01 |   KEY |   KEY |  Q1, 03 | SVCP |            |

| * 35 |         INDEX RANGE SCAN | INCIDENT_PATHTABLE_KEY_IX |     1.       |     2 (0) | 00:00:01 |   KEY |   KEY |  Q1, 03 | SVCP |            |

| * 36 |       TABLE ACCESS BY LOCAL INDEX ROWID | INCIDENT_PATHTABLE |     1.    42.     3 (0) | 00:00:01 |     1.     1.  Q1, 03 | SVCP |            |

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

PLAN_TABLE_OUTPUT

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

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

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

10 - access("SYS_P9".") PATHID '=' ID')

Access (SYS_PATH_REVERSE ("PATH") 15 - > = HEXTORAW ('02582E') AND SYS_PATH_REVERSE ("PATH") < HEXTORAW ('02582EFF'))

16 - access("SYS_P11".") RID "IS 'SYS_P9'." GET RID OF"AND TBL$ OR$ IDX$ PART$ NUM ("CORPAUDLIVE". "THE INCIDENT", 0,7,65535, "SYS_P9" "." " "RID") = TBL$ OR$ IDX$ PART$ NUM ("CORPAUDLIVE". "INCIDENT_PATHTAB

THE', 0,7,65535, ROWID))

filter ("SYS_P9". "ORDER_KEY" < = 'SYS_P11' "." " ORDER_KEY' AND 'SYS_P11 '. "" ORDER_KEY "< SYS_ORDERKEY_MAXCHILD ("SYS_P9". "ORDER_KEY")) "

20 filter (SYS_XMLI_LOC_ISTEXT ("SYS_P11". "LOCATOR", "SYS_P11" "." " PATHID') = 1)

21 - access("SYS_P11".") The VALUE "= 'John')

23 filter (SYS_XMLI_LOC_ISNODE ("SYS_P9". "LOCATOR") = 1 AND SYS_OP_BLOOM_FILTER (: BF0000, "SYS_P9".) " PATHID'))

PLAN_TABLE_OUTPUT

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

24 - filter("A".") INCIDENT_DATE' > = TIMESTAMP' 2014 - 10 - 01 00:00:00.000000000 "AND"A"". "" INCIDENT_DATE"< = TIMESTAMP' 2014 - 10 - 09 00:00:00.000000000' AND

"ITEM_2" = TBL$ OR$ IDX$ PART$ NUM ("INCIDENT", 0,7,65535, "A". ROWID))

25 filter ("ITEM_4" = TBL$ OR$ IDX$ PART$ NUM ("INCIDENT", 0,7,65535, "A".) ROWID))

30 - access (SYS_PATH_REVERSE ("PATH") > = HEXTORAW('027FF9') AND SYS_PATH_REVERSE ("PATH") < HEXTORAW ('027FF9FF'))

32 filter (SYS_XMLI_LOC_ISNODE ("SYS_P2". "LOCATOR") = 1) "

33 - access("SYS_P2".") GET RID OF"="A ". ROWID AND 'SYS_P2 '. ("' PATHID '=' ID ')

35 - access("SYS_P4".") GET RID OF"="A ". ROWID AND 'SYS_P2 '. "" ORDER_KEY "< ="SYS_P4. " "" ORDER_KEY "AND"SYS_P4 ". "" ORDER_KEY "< SYS_ORDERKEY_MAXCHILD ("SYS_P2". "ORDER_KEY")) "

filter ("SYS_P4". "RID"IS "SYS_P2"." GET RID OF"AND TBL$ OR$ IDX$ PART$ NUM("INCIDENT",0,7,65535,"SYS_P2".") "RID") = TBL$ OR$ IDX$ PART$ NUM ("INCIDENT_PATHTABL

E «(, 0,7,65535, ROWID)).

36 - filter("SYS_P4".") The VALUE '= 'clark' AND SYS_XMLI_LOC_ISTEXT ("SYS_P4".' LOCATOR', 'SYS_P4 '. (("" PATHID ') = 1).

PLAN_TABLE_OUTPUT

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

Note

-----

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

69 selected lines.

Elapsed time: 00:00:00.47

SQL > spool off

Thank you

CenterB

You must create a XMLIndex with two groups:

create table actionnew)

number of action_pk

action_date timestamp

action_detail xmltype

)

partition by (range (action_date)

partition values before_2015 less (timestamp ' 2015-01-01 00:00:00 ')

, partition values jan_2015 less (timestamp ' 2015-02-01 00:00:00 ')

, partition values feb_2015 less (timestamp ' 2015-03-01 00:00:00 ')

);

create index actionnew_sxi on actionnew (action_detail)

indexType is xdb.xmlindex

local

parameters (q'~)

Group my_group_1

XMLTable actionnew_xt1

"/ audit/action_details/screen_data/tables/table/row.

path of varchar2 (100) the columns "name".

, path of surname varchar2 (100) "first name".

Group my_group_2

XMLTable actionnew_xt2

"/ audit/action_details/fields.

path of varchar2 (100) the columns "name".

, path of surname varchar2 (100) "first name".

~'

);

Select x.*

to actionnew t

xmltable)

"/ audit/action_details/screen_data/tables/table/row.

in passing t.action_detail

path of varchar2 (100) the columns "name".

, path of surname varchar2 (100) "first name".

) x

where t.action_date between timestamp ' 2015-02-01 00:00:00 '

and timestamp ' 2015-03-01 00:00:00 '

and x.forename = 'anwardo. '

and x.surname = 'gram '.

;

Tags: Database

Similar Questions

  • CBO: full instead of bitmap index use, why table scan?

    I have a query in which it is clearly benefitial to use the bitmap index, rather oracle goes for the full table scan. Could you please shed some light on this? Because even a hint does not help, I guess that something prevents oracle (11.1.0.7.0) to use it in a sort of range index scan pass.

    installation program:
    create table test_distance (
    x_display number,
    y_display number,
    x_rough number(5,2) as (trunc(x_display,2)),
    y_rough number(5,2) as (trunc(y_display,2)));
    
    insert into test_distance (x_display,y_display) 
    (select dbms_random.value(-180,180), dbms_random.value(-90,90) from dual connect by level < 200000);
    
    create bitmap index test_bm_xrough on test_distance(x_rough);
    create bitmap index test_bm_yrough on test_distance(y_rough);
    
    create or replace function  western_bbox_longitude(x binary_double, y binary_double, radius binary_double) return number
    is
    begin
      --simplified
     return x - 0.0001*radius;
    end;
    /
    
    exec dbms_stats.gather_table_stats(user,'TEST_DISTANCE',cascade=>true,estimate_percent=>100);
    several select statements:
    --remember x and y values and use them in the subsequent queries.
    select * from test_distance where rownum = 1;
    
    alter session set statistics_level = all;
    
    --no bind variable, no function call -> proper plan
    select * from test_distance where x_rough = 16.14 and y_rough = -35.53;
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    --with bind variable, no function call -> still proper plan
    select * from test_distance where x_rough = :xin and y_rough = :yin;
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    --using between, bind variable, no function call -> proper plan
    select * from test_distance where x_rough between :xin-0.01 and :xin and y_rough between :yin-0.01 and :yin;
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    
    --full table scan, why?
    select td.*,
    trunc(western_bbox_longitude(:xin,:yin,:radius),2)
    from test_distance td 
    where x_rough = trunc(
    western_bbox_longitude(:xin,:yin,:radius),2);
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    --forcing oracle to use the index results in bitmap index full instead of range scan, why?
    select /*+ index( td test_bm_xrough) */ td.*,
    trunc(western_bbox_longitude(:xin,:yin,:radius),2)
    from test_distance td 
    where x_rough = trunc(
    western_bbox_longitude(:xin,:yin,:radius),2);
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    --guessing it might be related to the selectivity of the function doesn't change the plan either
    associate statistics with functions western_bbox_longitude default selectivity 0.001;

    Ah sorry, I somehow read the wrong line in your initial statement where it between the function has been used.

    Yes it is possible that the selectivity of the function plays a role here. More likely may be the order of execution for the undeterministic functions is then different for literals. However, you can try to work around this problem by using a few different approaches.

    encapsulate the function inside a double subseelct

    select /*+ index( td test_bm_xrough) */ td.*,
       (select trunc(western_bbox_longitude(:xin,:yin,:radius),2))
    from test_distance td
    where x_rough = (select trunc(western_bbox_longitude(:xin,:yin,:radius),2) from dual);
    

    This should allow to cache the result of the function to a certain extent. Otherwise, the result of the function may be recalculated for each row in the test_distance table.

    The same can be achieved with a WITH clause
    not tested

    with wboxlong as (select trunc(western_bbox_longitude(:xin,:yin,:radius),2) xrough from dual)
    select /*+ index( td test_bm_xrough) */ td.*,
       x.xrough
    from test_distance td
    join wboxlong x on td.x_rough = x.xrough
    

    Also note that your tip worked. Oracle uses the bitmap indexes to access the data. Index indicator indicates to the CBO to use this index if possible, but is not on the path. If you want a different plan, you can try to apply also the path combined with a suspicion as NO_INDEX_FFS (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements006.htm#SQLRF50413).

    Published by: Sven w. on January 3, 2011 18:57

  • Index on non unique values in order to avoid the full table scan

    I have a table with > 100 k records. The table is updated only during the race every night. All columns except one have non - unique values and I am querying the table with this request.

    COL3 - non - unique values - only 40 distinct values
    unique values - no - COL4 - 1000 distinct values
    last_column - 100 k unique values

    Select last_column in the table_name where in (...) col3 or col4 (...)

    I tried to create a Bitmap index individually on col3 and col4 and also combined. However, in both cases, it performs a full table scan.

    Please, help me optimize this query as it is used in the term altogether the system and the cost of the query is very high around 650.

    I don't have much experience with popular indexes then all tracks.

    Thank you
    Sensey

    Published by: user13312817 on November 7, 2011 11:32

    An alternative might be to use a union instead and the 2 index:

    create index my_index1 on my_table (col3, last_column) compress 1;
    create index my_index2 on my_table (col4, last_column) compress 1;

    Select last_column from my_table
    where col3 in (...)
    Union
    Select last_column from my_table
    where col4 (...)

    In other words, if the UNION would apply here whereas in double values for last_column will be deleted.

  • FULL TABLE SCAN even with the index, but why?

    Could someone please explain why I'd get FULL TABLE SCAN explain plan results when joining 2 tables on columns that already have clues about them? For example,.
    consider this fictional scenario:

    employee table with columns:
    employee # (primary key column)
    name

    address table with columns:
    employee # (foreign key to employee.employee #)
    subscription_type
    address

    Select Employee.Name since it is, address.address_type, address.address
    where employee.employee # = address.employee #.

    This query shows a full table scan in terms of the explain command.

    Full scan of the table is not necessarily slow and index access is not necessarily fast.

    You will recover, no doubt, most if not all the ranks on both sides. The fastest way to retrieve each row in a table is to do a table scan. Using an index, and a single block of reading for each row in a table is much less effective than to do a table scan.

    Justin

  • Why full when I index the table scan

    Can someone quickly tell me why this statement will generate a full table scan if RECEIPT_NO for both tables have a unique index.


    Select * from agency_ledger where a.RECEIPT_NO in (select receipt_no from temp)

    concerning

    Hello

    Two reason I can think
    (1) statistics are not collected or are at a standstill.
    (2) oracle considers the hash join full table scan more appropriate than the nested loop + scan small index.

    Post your explain plain and let us know stats is collected or not.
    In addition, let us know what is the percentage of rows are expected in output compared to the total number of lines.

    Concerning
    Anurag Tibrewal.

  • Why xmlindex is not used in the slow queries on xml binary table eval?

    I run a slow simple query on Oracle 11.2.0.1 database server that does not use a xmlindex. Instead, a full table scan against the table eval binary xml occurs. This is the query:
     select -- /*+ NO_XMLINDEX_REWRITE no_parallel(eval)*/
          defid from eval,
          XMLTable(XMLNAMESPACES(DEFAULT 'http://www.cigna.com/acme/domains/eval/2010/03',
          'http://www.cigna.com/acme/domains/derived/fact/2010/03' AS "ns7"),
          '$doc/eval/derivedFacts/ns7:derivedFact' passing eval.object_value as "doc" columns defid varchar2(100) path 'ns7:defId'
           ) eval_xml
    where eval_xml.defid in ('59543','55208'); 
    The predicate is not selective at all - the number of rows returned is the same as the number of rows in table (325 550 in the eval table xml documents). When different values are used, which brings the number of lines down to ~ 33%, the xmlindex still is not used - as is expected in a purely relational XML environment.

    My question is why would'nt the xmlindex be used somehow full scan compared to a sweep of full table that cross the xml for each record in paper table eval?
    FFS suspicion would apply to a field of type xmlindex index?

    Here is the definition of xmlindex:
     CREATE INDEX "EVAL_XMLINDEX_IX" ON "EVAL" (OBJECT_VALUE)
      INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
      ('XMLTable eval_idx_tab XMLNamespaces(DEFAULT ''http://www.cigna.com/acme/domains/eval/2010/03'',
      ''http://www.cigna.com/acme/domains/derived/fact/2010/03'' AS "ns7"),''/eval'' 
           COLUMNS defId VARCHAR2(100) path ''/derivedFacts/ns7:derivedFact/ns7:defId''');
    Here is the definition of table eval:
     CREATE
      TABLE "N98991"."EVAL" OF XMLTYPE
      (
        CONSTRAINT "EVAL_ID_PK" PRIMARY KEY ("EVAL_ID") USING INDEX PCTFREE 10
        INITRANS 4 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT
        1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1
        FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE
        DEFAULT) TABLESPACE "ACME_DATA" ENABLE
      )
      XMLTYPE STORE AS SECUREFILE BINARY XML
      (
        TABLESPACE "ACME_DATA" ENABLE STORAGE IN ROW CHUNK 8192 CACHE NOCOMPRESS
        KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS
        2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT)
      )
      ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
      (
        "EVAL_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03"; (::)
    /eval/@eval_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE))),
        "EVAL_CAT" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";/eval/@category'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "ACME_MBR_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";/eval/@acmeMemberId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "EVAL_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";/eval/@evalId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50)))
      )
      PCTFREE 0 PCTUSED 80 INITRANS 4 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
      (
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DATA" ; 
    Purified sample extract of XML:
    <?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><eval createdById="xxxx" hhhhMemberId="37e6f05a-88dc-41e9-a8df-2a2ac6d822c9" category="eeeeeeee" eval_dt="2012-02-11T23:47:02.645Z" evalId="12e007f5-b7c3-4da2-b8b8-4bf066675d1a" xmlns="http://www.xxxxx.com/vvvv/domains/eval/2010/03" xmlns:ns2="http://www.cigna.com/nnnn/domains/derived/fact/2010/03" xmlns:ns3="http://www.xxxxx.com/vvvv/domains/common/2010/03">
       <derivedFacts>
          <ns2:derivedFact>
             <ns2:defId>12345</ns2:defId>
             <ns2:defUrn>urn:mmmmrunner:Medical:Definition:DerivedFact:52657:1</ns2:defUrn>
             <ns2:factSource>tttt Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52600</ns2:defId>
             <ns2:defUrn>urn:ddddrunner:Medical:Definition:DerivedFact:52600:2</ns2:defUrn>
             <ns2:factSource>cccc Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>null</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>59543</ns2:defId>
             <ns2:defUrn>urn:ddddunner:Medical:Definition:DerivedFact:52599:1</ns2:defUrn>
             <ns2:factSource>dddd Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>INT</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
                    ...
                With the repeating <ns2:derivedFact> element continuing under the <derivedFacts>
    Oracle XML DB 11g Release 2 Developer's Guide is not much help...

    Any help is appreciated.

    Kind regards
    Rick Blanchard

    XMLIndex definition is not correct, for the following reasons:

    In the COLUMNS clause, the path expression is compared to the context from the main event of XQuery item (HERE "/ eval").
    If you use an initial slash as you did, this indicates that the context item is an element of "derivedFacts" (which is not correct since it is an "eval" element).
    Therefore, the path points to no existing node:

    derivedFact XMLTYPE path ''/derivedFacts/ns7:derivedFact'' virtual
    

    There is a mismatch between the statements of prefix ns7, probably a typing mistake?

    ''http://www.cigna.com/acme/domains/derived/fact/2010/03'' AS "ns7"
    ...
    ''http://www.cigna.com/acme/domains/derived/FACT/2010/03'' AS "ns7"
    

    What "eval_xml" is referring to here?

    passing eval_xml.derivedFact
    

    The path to "defId" don't go too:

    defId VARCHAR2(100) path ''/derivedFacts/ns7:derivedFact/ns7:defId''
    

    Try this one, it should help you to:

    CREATE INDEX "EVAL_XMLINDEX_IX" ON "EVAL" (OBJECT_VALUE)
    INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS (
    'XMLTable eval_idx_tab_I
      XMLNamespaces(''http://www.cigna.com/acme/domains/derived/fact/2010/03'' AS "ns7",
                    DEFAULT ''http://www.cigna.com/acme/domains/eval/2010/03''),
      ''/eval''
      COLUMNS
       eval_catt   VARCHAR2(50) path ''@category'',
       derivedFact XMLTYPE      path ''derivedFacts/ns7:derivedFact'' virtual
     XMLTable eval_idx_tab_II
      XMLNamespaces(''http://www.cigna.com/acme/domains/derived/fact/2010/03'' AS "ns7",
                    DEFAULT ''http://www.cigna.com/acme/domains/eval/2010/03''),
      ''/ns7:derivedFact'' passing derivedFact
      COLUMNS
       defId VARCHAR2(100) path ''ns7:defId'''
    );
    
  • Why is query on Table XMLTYPE ACME_CUST do a full Table Scan?

    Our Oracle 11 g Enterprise Edition Release 11.2.0.1.0 database, there is a query against a record in 25 214 table XMLTYPE ACME_CUST.
    SELECT rownum   AS seq,
          EID  AS eid,
          SUBSTR(CUST_ID, 1, INSTR(CUST_ID, '|')-1) AS tgt_acme_customer_id,
          SUBSTR(CUST_ID, INSTR(CUST_ID, '|')   +1) AS src_acme_customer_id_list
        FROM
          (SELECT ac.eid EID,
            listagg(ac.acme_cust_id, '|') WITHIN GROUP (
          ORDER BY ac.acme_cust_id, ac.acme_cust_id) CUST_ID
          FROM ACME_CUST ac
          GROUP BY ac.eid
          HAVING COUNT(ac.acme_cust_id)>1)
    Explain the plan indicates:

    SELECT statement
    County
    VIEW
    FILTER
    Filter predicates
    Count (*) > 1
    GROUP SORT BY
    ACME_CUST FOR FULL TABLE

    The ACME_CUST Table has a virtual column defined on acme_cust_id as well as a corresponding index. He filed is also defined as the primary key.

    Here is the table reflect and associated States:
    CREATE
      TABLE "N98991"."ACME_CUST" OF XMLTYPE
      (
        CONSTRAINT "ACME_CUST_ID_PK" PRIMARY KEY ("ACME_CUST_ID") USING INDEX
        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 FLASH_CACHE DEFAULT CELL_FLASH_CACHE
        DEFAULT) TABLESPACE "ACME_DEV" ENABLE
      )
      XMLTYPE STORE AS SECUREFILE BINARY XML
      (
        TABLESPACE "ACME_DEV" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
        NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
        MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT)
      )
      ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
      (
        "EID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                               
    /customerProfile/@eid'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(15))),
      *bold*  "ACME_CUST_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                               
    /customerProfile/@id' *bold*
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "CRET_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                                                                                                       
    /customerProfile/@create_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE)))
      )
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
      (
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DEV" ;
    CREATE
      INDEX "N98991"."ACME_CST_CRET_DT_IDX" ON "N98991"."ACME_CUST"
      (
        "CRET_DT"
      )
      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 FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DEV" ;
    CREATE
      INDEX "N98991"."ACME_CST_EID_IDX" ON "N98991"."ACME_CUST"
      (
        "EID"
      )
      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 FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DEV" ;
    *bold*CREATE UNIQUE INDEX "N98991"."ACME_CUST_ID_PK" ON "N98991"."ACME_CUST"
      (
        "ACME_CUST_ID"
      )
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE *bold*
      (
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DEV" ;
      CREATE
        INDEX "N98991"."ACME_CUST_XMLINDEX_IX" ON "N98991"."ACME_CUST"
        (
          OBJECT_VALUE
        )
        INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
        (
          'XMLTABLE ACME_CUST_IDX_TAB XMLNamespaces (''http://www.cigna.com/acme/domains/commoncontact/2011/11'' as "cm",  default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),       
    ''/customerProfile''        
    columns       
    DOB date  PATH ''personInformation/cm:birthDate'',       
    FIRSTNAME varchar2(40)    PATH ''name/cm:givenName'',       
    LASTNAME varchar2(40)    PATH ''name/cm:surName'',       
    SSN varchar2(30)    PATH ''identifiers/ssn'',       
    MEMBERINFOS XMLType path ''memberInfos/memberInfo'' VIRTUAL        
    XMLTable acme_cust_lev2_idx_tab XMLNAMESPACES(default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),       
    ''/memberInfo'' passing MEMBERINFOS          
    columns          
    ami varchar2(40) PATH ''ami'',         
    subscId varchar2(50) PATH ''clientRelationship/subscriberInformation/subscriberId'',         
    employeeId varchar2(50) PATH ''systemKeys/employeeId'',         
    clientId varchar2(50) PATH ''clientRelationship/clientId''       
    '
        );
    CREATE UNIQUE INDEX "N98991"."SYS_C00384339" ON "N98991"."ACME_CUST"
      (
        "SYS_NC_OID$"
      )
      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 FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DEV" ;
    CREATE UNIQUE INDEX "N98991"."SYS_IL0000649948C00003$$" ON "N98991"."ACME_CUST"
      (
        PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576
        MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST
        GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
        TABLESPACE "ACME_DEV" PARALLEL (DEGREE 0 INSTANCES 0) ;
    Why is it not the ACME_CUST_ID_PK a unique index on the column virtual ACME_CUST_ID used in the plan to explain it?

    Any input would be much appreciated, like really puzzled here.

    Kind regards
    Rick

    Hi Richard,

    Event 10053 appears excessive for this situation.

    What is the problem?
    Set the event, run the query, disconnected the event, check the trace file, that's all.

    It is not excessive if it helps you understand what is happening and why an index is of no use in this situation.

    Tried the / * + INDEX_FFS (ACME_CUST_ID_PK) * / hint in the query "nested".

    Don't know what nested query, you reference, so if I misunderstood what you mean, just ignore the comment.
    What you posted earlier, it seems that you talk about this part:

    listagg(ac.acme_cust_id,'|') WITHIN GROUP (
    ORDER BY ac.acme_cust_id,ac.acme_cust_id) CUST_ID
    

    This isn't a nested query, it's a projection. All major works (recovery of lines) has already been done when it comes to this part.

    Maybe just to accept the performance of the queries because it is...

    Maybe you can try something else.

    See the document: Oracle XML DB: best practices, page 15 exodus 8:

    When there are multiple scalar values that must be consolidated or ordered, it is better to write
    with XMLTable build projecting all the columns to be ordered or grouped as shown
    below.

    Close example of your real need:

    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    
    SQL> create table xtab_cols of xmltype
      2  xmltype store as securefile binary xml;
    
    Table created.
    
    SQL> insert /*+ append */ into xtab_cols
      2  select xmlelement("ROW",
      3           xmlforest(
      4            TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,
      5            DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
      6            DEFAULT_LENGTH, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
      7            DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,
      8            CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,
      9            GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,
     10            V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM
     11           )
     12         )
     13  from dba_tab_cols
     14  where owner = 'SYS'
     15  ;
    
    57079 rows created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> set long 1000
    SQL> set pages 100
    SQL> select xmlserialize(document object_value) from xtab_cols where rownum = 1;
    
    XMLSERIALIZE(DOCUMENTOBJECT_VALUE)
    --------------------------------------------------------------------------------
    
      ACCESS$
      D_OBJ#
      NUMBER
      22
      N
      1
      7454
      C2083A
      C3031D18
      ,000134156157767642
      0
      1
      2012-01-28
      34794
      YES
      NO
      5
      0
      NO
      YES
      NONE
    
    
    SQL> exec dbms_stats.gather_table_stats(user, 'XTAB_COLS');
    
    PL/SQL procedure successfully completed.
    
    SQL> set autotrace traceonly
    SQL> set timing on
    SQL> set lines 120
    SQL> select x.table_name
      2       , listagg(x.column_name, ',') within group (order by column_id)
      3  from xtab_cols t
      4     , xmltable('/ROW' passing t.object_value
      5        columns table_name  varchar2(30) path 'TABLE_NAME'
      6              , column_name varchar2(30) path 'COLUMN_NAME'
      7              , column_id   number       path 'COLUMN_ID'
      8       ) x
      9  group by x.table_name
     10  ;
    
    4714 rows selected.
    
    Elapsed: 00:00:08.25
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 602782846
    
    ---------------------------------------------------------------------------------
    | Id  | Operation           | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |           |   466M|   101G|  1580K  (3)| 05:16:04 |
    |   1 |  SORT GROUP BY      |           |   466M|   101G|  1580K  (3)| 05:16:04 |
    |   2 |   NESTED LOOPS      |           |   466M|   101G|  1552K  (1)| 05:10:32 |
    |   3 |    TABLE ACCESS FULL| XTAB_COLS | 57079 |    12M|   408   (1)| 00:00:05 |
    |   4 |    XPATH EVALUATION |           |       |       |            |          |
    ---------------------------------------------------------------------------------
    
    Statistics
    ----------------------------------------------------------
              9  recursive calls
              1  db block gets
           1713  consistent gets
              0  physical reads
             96  redo size
         773516  bytes sent via SQL*Net to client
           3873  bytes received via SQL*Net from client
            316  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
           4714  rows processed
    

    And of course, even better after adding an XML index structured (4714 lines read in 1 s):

    SQL> CREATE INDEX xtab_cols_sxi ON xtab_cols (OBJECT_VALUE) INDEXTYPE IS XDB.XMLIndex
      2  PARAMETERS (
      3  q'#XMLTable my_xtab
      4  '/ROW'
      5  columns table_name varchar2(30) path 'TABLE_NAME'
      6        , column_name varchar2(30) path 'COLUMN_NAME'
      7        , column_id number path 'COLUMN_ID' #');
    
    Index created.
    
    Elapsed: 00:00:13.42
    SQL> select x.table_name
      2       , listagg(x.column_name, ',') within group (order by column_id)
      3  from xtab_cols t
      4     , xmltable('/ROW' passing t.object_value
      5        columns table_name  varchar2(30) path 'TABLE_NAME'
      6              , column_name varchar2(30) path 'COLUMN_NAME'
      7              , column_id   number       path 'COLUMN_ID'
      8       ) x
      9  group by x.table_name
     10  ;
    
    4714 rows selected.
    
    Elapsed: 00:00:01.00
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3303494605
    
    ------------------------------------------------------------------------------
    | Id  | Operation          | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |         | 57520 |  3201K|   174   (3)| 00:00:03 |
    |   1 |  SORT GROUP BY     |         | 57520 |  3201K|   174   (3)| 00:00:03 |
    |   2 |   TABLE ACCESS FULL| MY_XTAB | 57520 |  3201K|   171   (1)| 00:00:03 |
    ------------------------------------------------------------------------------
    
    Note
    -----
       - dynamic sampling used for this statement (level=2)
    
    Statistics
    ----------------------------------------------------------
            297  recursive calls
              1  db block gets
            989  consistent gets
              0  physical reads
            176  redo size
         773516  bytes sent via SQL*Net to client
           3873  bytes received via SQL*Net from client
            316  SQL*Net roundtrips to/from client
             21  sorts (memory)
              0  sorts (disk)
           4714  rows processed
    
  • Full table scan when using Array and struct.

    Guys,
    Sometimes I use the table to another table in primary key. The problem is that I have to use force index to avoid the full table scan. I don't think it's a good idea. Could someone help me? Code example follows.

    CREATE TYPE department_type () AS OBJECT
    DNO NUMBER (10),
    NAME VARCHAR2 (50).
    LOCATION VARCHAR2 (50)
    );

    CREATE TYPE dept_array AS TABLE OF department_type;

    Explain plan for
    SELECT *.
    OF ORD_HEADER H
    where there are
    (select 1 from table (dept_array (department_type (3535,-DNO))))
    "NAME", NAME
    'RENT', - LOCATION
    t))) WHERE H.BUID = T.BUID
    and H.ORDER_NUM = T.ORDER_NUM);
    Select * from table (DBMS_XPLAN.display);

    And it's because the Oracle conjecture for the number of rows in the collection is probably out path. In my view, that the optimizer guess that there will be approximately 8000 items in the table. If it is 100 k rows in the table, she believes she's going to have to go back to 8% of the lines, if she opts for the full table scan. If there is 1 M rows in the table, she believes that she will have to return only 0.8% of the lines, so he chooses to use the index. If you provide a hint of CARDINALITY which gives Oracle a better estimate of the number of elements in the array, assuming you have the elements significantly less than 8000 on average, you are much more likely to have access to the index.

    There is a wire askTom on [the cardinality hint when you use collections of PL/SQL in SQL | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:3779680732446 #15740265481549] it is quite worth reading.

    Justin

  • How do full table scan

    Hi all

    I have a table which is accesed by application every 5 seconds. Now, this table has several delete insert updates current. The table size is aprox 200 MB (high tide) and there is say 5 ranks, which will be a sentence of 20 to 30 KB. My CMS is say 2 GB. So now the stats are not met and there is no index in this table. Now I see full table scan as his wait event. Now, I want to know.

    How a scan full of tabel happens Oracle load the entire 200MB of data in the SGA and then do a table scan or should just the actual size used by the table IE 20 to 30 KB.

    Thank you

    A

    Hello

    high waters is precisely the limit up to which Oracle must read to be sure that all the data has been seen, so if you have only about 30 KB of data in the table, even if the data is in the first a few blocks from the table, a complete analysis must read the 200 MB (which is not so good but takes more time to read a few blocks). (the reason is that it was once the data written in this block and it triggered the HWM),

    You can reorganize the table (alter table mytable move or use DBMS_REDEFINITION so that you can do this, the application uses the table) to reset the HWM. ("If the current small" size used"is transient and if you expect the table to increase again to use 200 MB or more, don't need to reorg; do it if you are confident that the table will remain very weak)

    Best regards

    Brno Vroman.

  • 3 clues on 3 different columns, but explain plan shows full table scan for select queries

    I have a table - used and have index - functional ind1 (upper (f_name)), index - (emp_id) ind2 ind3 (upper (l_name) functional on 3 columns diffferent - what, emp_id, l_name respectively.) Now when I check explain plans for sub queries, they all have two shows complete table for the employee of the table scan. FYI - employee table is non-parittioned.

    Can someone tell me why 3 indices are not used here?

    (1) select emp_id, upper (f_name), upper (l_name) of the employee

    (2) select upper (f_name), mp_id, upper (l_name) of the employee

    where upper (f_name) = upper (f_name)

    and emp_id = emp_id

    and upper (l_name) = upper (l_name)

    If I can push oracle (version 11) to use these indexes somewho - maybe using tips? Any help is appreciated.

    
    Observations:
    
    SQL> desc emp1;
     Name                                      Null?    Type
     ----------------------------------------- -------- -----------------
     EMPID                                      NOT NULL NUMBER
     F_NAME                                    NOT NULL VARCHAR2(3)
     L_NAME                                    NOT NULL VARCHAR2(3)
     SALARY                                    NUMBER
     JOB_ROLE                                 VARCHAR2(5)
     DEPTID                                     NUMBER
    
    create index idx2 on emp1(empid);
    create index idx1 on emp1(upper(f_name) );
    create index idx3 on emp1(f_name,empid, l_name);
    exec dbms_stats.gather_table_stats(user,'EMP1', cascade=>true);
    
    8 rows selected.
    
    SQL> explain plan for
      2  select /*+ index_join(e idx1 idx2 idx3)*/   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select    upper(f_name),empid,upper(l_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select /*+ index_ffs(e idx3)*/   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 2496145112
    
    -----------------------------------------------------------------------------
    | Id  | Operation            | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -----------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select /*+ index(e idx3)*/   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select    upper(f_name),empid,upper(l_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> drop index idx3;
    
    Index dropped.
    
    SQL> explain plan for
      2     select   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3330885630
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      | 20000 |   175K|    18   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP1 | 20000 |   175K|    18   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> create index idx3 on emp1(f_name,empid, l_name );
    
    Index created.
    
    SQL>  explain plan for
      2     select   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    
  • How to avoid the full table scan?

    Hello

    I'm new to sql tuning. When I run the following query. Full table scan that happens and it does not use the index.

    SELECT / * + FIRST_ROWS (2) * / a0.t$ ttyp, a0.t$ amnt FROM forest112 WHERE a0.t$ amnt <>: 1 AND a0.t$ dapr =: 2 AND a0.t$ tapr =: 3;

    When I searched on the net, I found by changing the operator '<>' with 'NOT IN' we can make the query to use the index, but that will change the result. Is this true? What are the other changes that can be made to this query?

    I think that create under index may solve your problem, because in this case, it will not hit the table and get all desired data to index itself

    create index ind_1 on forest112 (tapr$ t, t$ WTSA, dapr$ t, t$ ttyp) compute statistics;

    Thank you

    Harman

  • Tuning sql insert that inserts 1 million lines makes a full table scan

    Hi Experts,

    I'm on Oracle 11.2.0.3 on Linux. I have a sql that inserts data into a table of History/Archives of a table main application based on the date. The application table has 3 million lines. and all the lines that are more then 6 months old must go in a table of History/Archives. This was decided recently, and we have 1 million rows that meet this criterion. This insertion in table archive takes about 3 minutes. Plan of the explain command shows a full table scan on the main Board - which is the right thing, because we are pulling 1 million rows in the main table in the history table.

    My question is that, is it possible that I can do this sql go faster?

    Here's the query plan (I changed the names of table etc.)

       INSERT INTO EMP_ARCH
       SELECT *
    FROM EMP M
    where HIRE_date < (sysdate - :v_num_days);
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        2      0.00       0.00          0          0          0           0
    Execute      2     96.22     165.59      92266     147180    8529323     1441230
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     96.22     165.59      92266     147180    8529323     1441230
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: 166
    Rows     Row Source Operation
    -------  ---------------------------------------------------
    1441401   TABLE ACCESS FULL EMP (cr=52900 pr=52885 pw=0 time=21189581 us)
    
    
    

    I heard that there is a way to use opt_param tip to increase the multiblock read County but did not work for me... I will be grateful for suggestions on this. can collections and this changing in pl/sql also make it faster?

    Thank you

    OrauserN

    (1) create an index on hire_date

    (2) tip 'additional' use in the 'select' query '

    (3) run ' alter session parallel DML'; before you run the entire statement

  • The query makes a full table scan?

    I have a simple select query that filters on the last 10 or 11 days of data in a table. In the first case, it runs in 1 second. In the second case it takes 15 minutes and still not done.

    I can say that the second query (11 days) makes a full table scan.
    -Why is this happening? ... I guess some kind of threshold?
    -Are there a way to avoid this? ... or encourage Oracle to play nice.

    I find confusing from the point of view before end/query to get very different performances.

    Jason
    Oracle 10g
    Toad quest 10.6

    CREATE TABLE delme10 AS 
    SELECT *
    FROM ed_visits
    WHERE first_contact_dt >= TRUNC(SYSDATE-10,'D');
    
    Plan hash value: 915912709
    
    --------------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT       |                   |  4799 |  5534K|  4951   (1)| 00:01:00 |
    |   1 |  LOAD AS SELECT              | DELME10           |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| ED_VISITS         |  4799 |  5534K|  4796   (1)| 00:00:58 |
    |*  3 |    INDEX RANGE SCAN          | NDX_ED_VISITS_020 |  4799 |       |    15   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("FIRST_CONTACT_DT">=TRUNC(SYSDATE@!-10,'fmd'))
    
    
    CREATE TABLE delme11 AS 
    SELECT *
    FROM ed_visits
    WHERE first_contact_dt >= TRUNC(SYSDATE-11,'D');
    Plan hash value: 1113251513
    
    -----------------------------------------------------------------------------------------------------------------
    | Id  | Operation              | Name      | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    -----------------------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT |           | 25157 |    28M| 14580   (1)| 00:02:55 |        |      |            |
    |   1 |  LOAD AS SELECT        | DELME11   |       |       |            |          |        |      |            |
    |   2 |   PX COORDINATOR       |           |       |       |            |          |        |      |            |
    |   3 |    PX SEND QC (RANDOM) | :TQ10000  | 25157 |    28M| 14530   (1)| 00:02:55 |  Q1,00 | P->S | QC (RAND)  |
    |   4 |     PX BLOCK ITERATOR  |           | 25157 |    28M| 14530   (1)| 00:02:55 |  Q1,00 | PCWC |            |
    |*  5 |      TABLE ACCESS FULL | ED_VISITS | 25157 |    28M| 14530   (1)| 00:02:55 |  Q1,00 | PCWP |            |
    -----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       5 - filter("FIRST_CONTACT_DT">=TRUNC(SYSDATE@!-11,'fmd'))

    This seems to change the plan to explain it...

    alter session set optimizer_index_cost_adj=10;
    
  • causing trunc of the full Table Scans

    I have a situtaion here where my query is this.

    SQL > select count (1) in the HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5 = 'HD' and CUST_STATUS in ('UP', "UUP") and trunc (FIRST_ACTVN_DATE) = trunc (sysdate);

    COUNT (1)
    ----------
    6

    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 3951750498

    ---------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    ---------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 1. 10. 13904 (1) | 00:02:47 |
    | 1. GLOBAL TRI | 1. 10 | | | | |
    | 2. SIMPLE LIST OF PARTITION. 1. 10. 13904 (1) | 00:02:47 | 12. 12.
    |* 3 | TABLE ACCESS FULL | HBSM_SM_ACCOUNT_INFO | 1. 10. 13904 (1) | 00:02:47 | 12. 12.
    ---------------------------------------------------------------------------------------------------------------

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

    3 filter (("CUST_STATUS" = "UP" OU "CUST_STATUS" = 'UUP') AND)
    TO_DATE (INTERNAL_FUNCTION ("FIRST_ACTVN_DATE")) = TO_DATE (TO_CHAR(SYSDATE@!)))

    16 selected lines.


    If I remove the trunc clause in the query performance improves significantly the results are false.

    SQL > select count (1) in the HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5 = 'HD' and CUST_STATUS in ('UP', "UUP") and FIRST_ACTVN_DATE = trunc (sysdate);

    COUNT (1)
    ----------
    0


    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 454529511

    ---------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    ---------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 1. 40. 47 (0) | 00:00:01 |
    |* 1 | TABLE ACCESS BY INDEX ROWID | HBSM_SM_ACCOUNT_INFO | 1. 40. 47 (0) | 00:00:01 | 12. 12.
    |* 2 | INDEX RANGE SCAN | IND_FIRST_ACTVN_DATE | 51. 4 (0) | 00:00:01 |
    ---------------------------------------------------------------------------------------------------------------------------


    Can anyone please help me by which I can get the right data, and I can also prevent such full table scans.

    Unless you use a functional index, apply any function to an indexed column prevents the use of the index.

    The way around it in your case is to realize that

    select count(1) from HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5='MH' and CUST_STATUS in ('UP','UUP') and trunc(FIRST_ACTVN_DATE) = trunc(sysdate)
    

    Really asking that the FIRST_ACTVN_DATE are sometimes today. You can rewrite so as

    select count(1) from HBSM_SM_ACCOUNT_INFO where OPTIONAL_PARM5='MH' and CUST_STATUS in ('UP','UUP')
    and FIRST_ACTVN_DATE >= trunc(sysdate)
    and FIRST_ACTVN_DATE < trunc(sysdate) + 1
    

    Note that this may not always use the index according to the number of lines are the date of the day compared to how many are outside today's date.

    Also, when you post, don't forget to put your code between

     tags and to post create table scripts and sample data inserts.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    
  • Confusion of full Table Scan

    Hello experts,

    I am on 11g R2 RHEL5, I have a general question here, oracle said complete random for table scan reads are slower sequential reading, as far as my knowledge a sequential read is a monobloc read into the buffer cache, and read a straggling is a multiblock read that can occur for a full restricted index scan or a full table scan. My question is what is a shuffle? and how it is different from the sequential reading? on the technical side... Please put some light on these technical terms, so that I can work on the setting. There is also a warrant RANDOM i/o.

    In a very brief way, the scan would be something like, you ask for the first time for employees starting with the name 'Aman' (wasn't there a lot with this name) to access using an index be a better choice (perhaps not a good example of a column containing names in real time. Example is just for the sake of discussion) then asking with the name of 'John '.

    Aman...

Maybe you are looking for

  • no known viruses for macOS Sierra?

    Recently, I received a popup warning that seemed to know my location, the ISP and the operating system recommended use MacKeeper to remove a virus that it has scanned.  Address Web was apple.com

  • About "any promotion"

    It is true the promotion? I bought a Toshiba Satellite laptop.I registered on the http://toshiba-europe.com/registration link, but I have received no confirmation. If my computer is stolen or broken where I go or who should I contact?

  • digital digital indicator of coercion dot

    Using the evaluation version of LabVIEW 2013 64-bit. I have a digital U32 digital indicator on the front panel. I'm passing a reference of it to a Subvi. The Subvi has a control that is the server VI-> generic class-> GObject-> control-> digital-> di

  • 15 - r052nd: RAM replacement HP 15-r052nd

    Hello people! I have a computer laptop 15-r052nd HP for about 3-4 months.Recently, I noticed that my laptop used about 99% memory while doing the program so I want to upgrade my memory.This is no big problem for me. But 1 problem, maybe a problem of

  • Deleted file keeps reappearing at the beginning upward

    Hello Recently, I downloaded and installed a computer program. After some of my files etc. have been deleted, I uninstalled the program. Now, every time I start or restart my comp., the ghost appears to new "Verification Verification of updates, plea