Create indexes for an XMLType column.

Hello

I have a table that has a column of XMLType, the XSD is saved in DB. The XML is something like -

< primary >
< sub1 >
< child1_1 / >
< child1_2 / >
< child1_3 / >
< / sub1 >
< sub2 >
< child2_1 / >
< child2_2 / >
< child2_3 / >
< / sub2 >
< sub3 >
< child31_1 / >
< child3_2 / >
< child3_3 / >
< / sub3 >
< / elementary school >

I want to create indexes for child nodes. I read THAT XML structure cannot have collection as index it should be singleton.
So can someone tell me no work around to create indexes for these nodes, or whatever it is that I missed as follows.

Thank you

#1. Since you're on 11g stop using the syntax of depricated... (extractValue, table (xmlsequence))

SQL> create table PURCHASEORDER_TAB
  2  (
  3    PID number(4),
  4    PURCHASEORDER XMLTYPE
  5  )
  6  xmltype column PURCHASEORDER
  7  store as OBJECT RELATIONAL
  8  XMLSCHEMA "http://localhost:80/publishedContent/SB-XML/xsd/2010/purchaseOrder.xsd" Element "PurchaseOrder"
  9  /

Table created.

SQL> select table_name, table_type_name
  2  from user_nested_tables where parent_table_name = 'PURCHASEORDER_TAB';

TABLE_NAME                     TABLE_TYPE_NAME
------------------------------ ------------------------------
SYS_NTdmDOdAAMQsuXdRy6lc0H/A== Action64442_COLL
SYS_NT8EIzAbUOQFGN2u6hCXP39g== LineItem64443_COLL

SQL> rename "SYS_NT8EIzAbUOQFGN2u6hCXP39g==" to LINEITEM_NT
  2  /

Table renamed.

SQL> create index QTY_INDEX on LINEITEM_NT ("Quantity");

Index created.

SQL> set autotrace on explain lines 250 pages 50 trimspool on
SQL> --
SQL> select t.pid, quantity
  2    from PURCHASEORDER_TAB t,
  3         XMLTABLE
  4         (
  5           '/PurchaseOrder/LineItems/LineItem'
  6           passing t.PURCHASEORDER
  7           columns
  8           QUANTITY number(4) path 'Quantity'
  9         )
 10   where QUANTITY = 3
 11  /

no rows selected

Execution Plan
----------------------------------------------------------
Plan hash value: 1929272390

--------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                   |     1 |    46 |     3   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                |                   |       |       |            |          |
|   2 |   NESTED LOOPS               |                   |     1 |    46 |     3   (0)| 00:00:01 |
|*  3 |    TABLE ACCESS FULL         | LINEITEM_NT       |     1 |    23 |     2   (0)| 00:00:01 |
|*  4 |    INDEX UNIQUE SCAN         | SYS_C00429284     |     1 |       |     0   (0)| 00:00:01 |
|   5 |   TABLE ACCESS BY INDEX ROWID| PURCHASEORDER_TAB |     1 |    23 |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter(CAST(TO_NUMBER(TO_CHAR("Quantity")) AS number(4) )=3)
   4 - access("NESTED_TABLE_ID"="T"."SYS_NC0002900030$")

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL> select t.pid, quantity
  2    from PURCHASEORDER_TAB t,
  3         XMLTABLE
  4         (
  5           '/PurchaseOrder/LineItems/LineItem'
  6           passing t.PURCHASEORDER
  7           columns
  8           QUANTITY number(12,4) path 'Quantity'
  9         )
 10   where QUANTITY = 3
 11  /

no rows selected

Execution Plan
----------------------------------------------------------
Plan hash value: 3093486066

--------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                   |     1 |    46 |     2   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                |                   |       |       |            |          |
|   2 |   NESTED LOOPS               |                   |     1 |    46 |     2   (0)| 00:00:01 |
|   3 |    TABLE ACCESS FULL         | PURCHASEORDER_TAB |     1 |    23 |     2   (0)| 00:00:01 |
|*  4 |    INDEX RANGE SCAN          | QTY_INDEX         |     1 |       |     0   (0)| 00:00:01 |
|*  5 |   TABLE ACCESS BY INDEX ROWID| LINEITEM_NT       |     1 |    23 |     0   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   4 - access("Quantity"=3)
   5 - filter("NESTED_TABLE_ID"="T"."SYS_NC0002900030$")

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL> select t.pid, quantity
  2    from PURCHASEORDER_TAB t,
  3         XMLTABLE
  4         (
  5           '/PurchaseOrder/LineItems/LineItem'
  6           passing t.PURCHASEORDER
  7           columns
  8           QUANTITY path 'Quantity'
  9         )
 10   where QUANTITY = 3
 11  /

no rows selected

Execution Plan
----------------------------------------------------------
Plan hash value: 3093486066

--------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                   |     1 |    46 |     2   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                |                   |       |       |            |          |
|   2 |   NESTED LOOPS               |                   |     1 |    46 |     2   (0)| 00:00:01 |
|   3 |    TABLE ACCESS FULL         | PURCHASEORDER_TAB |     1 |    23 |     2   (0)| 00:00:01 |
|*  4 |    INDEX RANGE SCAN          | QTY_INDEX         |     1 |       |     0   (0)| 00:00:01 |
|*  5 |   TABLE ACCESS BY INDEX ROWID| LINEITEM_NT       |     1 |    23 |     0   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   4 - access("Quantity"=3)
   5 - filter("NESTED_TABLE_ID"="T"."SYS_NC0002900030$")

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL> SELECT t.pid, extractValue(Value(sta),'/LineItem/Quantity')
  2    FROM PURCHASEORDER_TAB t,
  3    table(xmlsequence(extract(t.purchaseOrder,'/PurchaseOrder/LineItems/LineItem'))) sta
  4    WHERE extractValue(Value(sta),'/LineItem/Quantity')= 3
  5  /

no rows selected

Execution Plan
----------------------------------------------------------
Plan hash value: 3093486066

--------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                   |     1 |    46 |     2   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                |                   |       |       |            |          |
|   2 |   NESTED LOOPS               |                   |     1 |    46 |     2   (0)| 00:00:01 |
|   3 |    TABLE ACCESS FULL         | PURCHASEORDER_TAB |     1 |    23 |     2   (0)| 00:00:01 |
|*  4 |    INDEX RANGE SCAN          | QTY_INDEX         |     1 |       |     0   (0)| 00:00:01 |
|*  5 |   TABLE ACCESS BY INDEX ROWID| LINEITEM_NT       |     1 |    23 |     0   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   4 - access("Quantity"=3)
   5 - filter("NESTED_TABLE_ID"="T"."SYS_NC0002900030$")

Note
-----
   - dynamic sampling used for this statement (level=2)

SQL>

Note the first example XMLTable does not use the index because the data type of AMOUNT is given wrong...

Tags: Database

Similar Questions

  • Creating indexes in the XMLType column

    Hello

    I have the following for XML document stored as an XMLType column.

    < ocaStatus xmlns = "http://xmlbeans.apache.org/ocastatus" > < status > < > 934 statusCode < / statusCode > < statusDate > Wed Apr 07 16:05:53 GMT + 05:30 2010 < / statusDate > < userId > u0121845 < / userId > < comment > sent to FLC < / comment > < / status > < status > < statusCode > 934 < / statusCode > < statusDate > Wed Apr 07 15:58:25 GMT + 05:30 2010 < / statusDate > < userId > u0121845 < / username > < Comment > sent to FLC < / comment > < / status > < status > < statusCode > 934 < / statusCode > < statusDate > Wed Apr 07 15:54:02 GMT + 05:30 2010 < / statusDate > < userId u0121845 > < / userId > < comment > sent to FLC < / comment > < / status > < status > < statusCode > 750 < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < u0121845 userId > < / userId > < comment > metadata of the Document is correct. < / comment > < / status > < status > < statusCode > 934 < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < userId > u0121845 < / userId > < comment > sent to FLC < / comment > < / status > < status > < statusCode > 932 < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < userId > u0121845 < / username > < comment > loaded Novus < /. comment > < / status > < status > < > 700 statusCode < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < userId u0121845 > < / userId > < comment > Document is deleted from the OCA. < / comment > < / status > < / ocaStatus >

    I created as a result of the clues in the XML
    CREATING INDEX 'OCA_DEV '. "' OCA_STATUS_CODE_INDEX ' ON 'OCA_DEV '. "DOCUMENT_STATUS_XML"(EXTRACTVALUE('/ocaStatus/status/statusCode'));
    CREATING INDEX 'OCA_DEV '. "' OCA_STATUS_DATE_INDEX ' ON 'OCA_DEV '. "DOCUMENT_STATUS_XML"(EXTRACTVALUE('/ocaStatus/status/statusDate'));

    However, the problem is that I will be having several status within each XML that violates the indexing.
    Is there a way I can still create indexes for multiple State values in each XML file?

    Thanks in advance.

    Hello

    Take a look at the manual xdb (which version do you use?), for the 10.2 version, see: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb04cre.htm#sthref596
    It describes how you can index an XMLTYPE. Because you describe how you use, take a look at your needs.

    In 11G, you have the XMLINDEX to xmltypes indexing, you will find information here: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb_indexing.htm#CHDFCGGI

    Herald tiomela
    Superconsult.nl

  • Creating INDEX on a BLOB column in a separate tablespace

    Hello


    Our database contains 2 storage spaces :

    -Tablespace DATA : is reserved to hold the data.

    -Tablespace INDX: is reserved to hold the index.


    For some reason, that we must create the indexes on columns of type blob and the pending order are:

    SQL > CREATE INDEX my_index ON DOC_CONTENTS (doc_content) INDEXTYPE IS CTXSYS. CONTEXT;  / / doc_content a blob type.

    SQL> index created

    Now, all indexes are created in the tablespace for DATA that is not good, they should be created in the tablespace INDX (now is empty)

    For this reason, and after a search, I specified the tablespace INDX , which will contain the index, and the used command is:

    SQL > CREATE INDEX my_index ON DOC_CONTENTS (doc_content) INDEXTYPE IS CTXSYS. CONTEXT TABLESPACE INDX;

    *

    ERROR on line 1:

    ORA-29850: invalid option for creating domain index

    NB: also, when I try to use the same command with varchar column, it works.

    SQL > CREATE INDEX my_index ON DOC_CONTENTS (doc_name) TABLESPACE INDX;  / / doc_content a type VARCHAR2.

    SQL> index created


    Do you have an idea on how to create indexes on a blob column in a different tablespace?

    This question has nothing to do with the Oracle objects, but is related to Oracle Text, then perhaps that some moderator moves text objects.

    To specify a storage space for a ctxsys.context Oracle Text index domain index tables, you must create a storage preference, specify storage spaces in attributes of this preference, then use this preference in settings of creating index.  Please see the example below which shows first create domain index tables in the default users tablespace, then the creation of the field tables to be indexed in the example tablespace.

    Scott@orcl_11gR2 >-test environment:

    Scott@orcl_11gR2 > doc_contents CREATE TABLE

    2 (doc_content BLOB)

    3.

    Table created.

    Scott@orcl_11gR2 > INSERT INTO doc_contents VALUES

    2 (UTL_RAW. CAST_TO_RAW ("test data"))

    3.

    1 line of creation.

    Scott@orcl_11gR2 >-create domain index tables in default users tablespace:

    Scott@orcl_11gR2 > my_index CREATE INDEX

    2 doc_contents (doc_content)

    3 INDEXTYPE IS CTXSYS. FRAMEWORK

    4.

    The index is created.

    Scott@orcl_11gR2 > SELECT index_name, nom_tablespace

    2 FROM user_indexes

    3. WHERE index-name LIKE '% MY_INDEX % '.

    4.

    INDEX_NAME TABLESPACE_NAME

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

    MY_INDEX

    DR.$ MY_INDEX$ X USERS

    2 selected lines.

    Scott@orcl_11gR2 > SELECT table_name, nom_tablespace

    2 FROM user_tables

    3 WHERE table_name LIKE '% MY_INDEX % '.

    4.

    TABLE_NAME, TABLESPACE_NAME

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

    DR. MY_INDEX$ I HAVE USERS

    USERS R DR$ MY_INDEX$

    DR.$ MY_INDEX$ N

    DR.$ MY_INDEX$ K

    4 selected lines.

    Scott@orcl_11gR2 >-creating the tables index field in example of tablespace:

    Scott@orcl_11gR2 > my_index DROP INDEX

    2.

    The index is deleted.

    Scott@orcl_11gR2 > start

    2 ctx_ddl.create_preference ("mystore', 'BASIC_STORAGE'");

    3 ctx_ddl.set_attribute ("mystore', 'I_TABLE_CLAUSE',")

    4 "tablespace storage example (original 1 K) ');

    5 ctx_ddl.set_attribute ("mystore', 'K_TABLE_CLAUSE',")

    6 "tablespace storage example (original 1 K) ');

    7 ctx_ddl.set_attribute ("mystore', 'R_TABLE_CLAUSE',")

    8 ' lob tablespace storage example (original 1 K)

    9 (data) store as (storage off in row cache)');

    10 ctx_ddl.set_attribute ("mystore', 'N_TABLE_CLAUSE',")

    11 "tablespace storage example (original 1 K) ');

    12 ctx_ddl.set_attribute ("mystore', 'I_INDEX_CLAUSE',")

    13 ' example of tablespace storage (initial 1 K) compress 2 ');

    14 ctx_ddl.set_attribute ("mystore', 'P_TABLE_CLAUSE',")

    15 "tablespace storage example (original 1 K) ');

    16 ctx_ddl.set_attribute ("mystore', 'S_TABLE_CLAUSE',")

    17 "tablespace storage example (original 1 K) ');

    18 end;

    19.

    PL/SQL procedure successfully completed.

    Scott@orcl_11gR2 > my_index CREATE INDEX

    2 doc_contents (doc_content)

    3 INDEXTYPE IS CTXSYS. FRAMEWORK

    4 PARAMETERS ('STORAGE mystore')

    5.

    The index is created.

    Scott@orcl_11gR2 > SELECT index_name, nom_tablespace

    2 FROM user_indexes

    3. WHERE index-name LIKE '% MY_INDEX % '.

    4.

    INDEX_NAME TABLESPACE_NAME

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

    MY_INDEX

    DR.$ MY_INDEX$ X FOR EXAMPLE

    2 selected lines.

    Scott@orcl_11gR2 > SELECT table_name, nom_tablespace

    2 FROM user_tables

    3 WHERE table_name LIKE '% MY_INDEX % '.

    4.

    TABLE_NAME, TABLESPACE_NAME

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

    DR. MY_INDEX$ I EXAMPLE

    DR.$ MY_INDEX$ R EXAMPLE

    DR.$ MY_INDEX$ N

    DR.$ MY_INDEX$ K

    4 selected lines.

    Post edited by: BarbaraBoehmer (corrected for error due to the already existing preference)

  • Creating indexes for the table

    can someone help me how to create indexes in the table. I m creating own table... I need to select a particular field in the table. So I need to calculate the index position. I use my code like this,

    This will returnthe number of columns in the table.

    Class array

    {

    private int Table_Index()
    {
    for (int x = 0; x)<>
    {
    table_index = x;
    }
    Return table_index;
    }

    }

    MainClass can I get this length of Index

    Table T1;

    int t1 is T1. Table_Index();

    This property returns my length (4) of table column

    Using this index (t1) I HAV to see what position I'm at table now...

    someone help me...

    You can use a listfield, he supports methods to get the selected row and its contents.

  • How to create indexes for the great table of telecom

    Hello

    I'm working on DB 10 G on a 5 REHL for telecommunications company with more than 1 million saved per day, we need speed up the result of the query.
    We know, there are several types of INDEX and I need professional advice to create a suitable,

    many of our requests depend on the MSID (the MAC address of the Modem) column,
       
    Name           Null Type         
    -------------- ---- ------------ 
    STREAMNUMBER        NUMBER(9)    
    MSID                VARCHAR2(20) 
    USERNAME            VARCHAR2(20) 
    DOMAIN              VARCHAR2(20) 
    USERIP              VARCHAR2(16) 
    CORRELATION_ID      VARCHAR2(64) 
    ACCOUNTREASON       NUMBER(3)    
    STARTTIME           VARCHAR2(14) 
    PRIORTIME           VARCHAR2(14) 
    CURTIME             VARCHAR2(14) 
    SESSIONTIME         NUMBER(9)    
    SESSIONVOLUME       NUMBER(9)    
    .
    .
    .
    Please help,

    Hello

    first of all, think of all these SQL for the subquery on MAX (fairy) with analytical functions, the examples given on AskTom of rewriting: http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:9843506698920

    So I'll start with a normal index the MSID (but I think you already have), but provide a compression on the column, I think the same value MSID exist several times in the table. If the performance is not satisfactory or that the plan is not the best, then an option to include more columns can help you.

    I think that the first part of the answer will bring more gain.

    Herald tiomela
    http://htendam.WordPress.com

  • Doubt in create index.

    Hello
    I tried to create indexes on the same column in the same table as below, and I could see the difference also as below.
    When I gave 'BR_CODE', in dba_ind_columns, it appears as SYS_NC00082$. Why is it so? Can you get it someone please let me know the difference?

    create index IDX_BRCODE on BCT (BR_CODE, BANK_CODE);

    The index is created.

    SQL > select index_name, column_name from dba_ind_columns where table_name = "BCT";

    INDEX_NAME COLUMN_NAM
    ------------------------------ ----------
    IDX_BRCODE BR_CODE
    IDX_BRCODE BANK_CODE

    create index IDX_BRCODE1 on BCT ('BR_CODE', BANK_CODE);

    The index is created.

    SQL > select index_name, column_name from dba_ind_columns where table_name = "BCT";

    INDEX_NAME COLUMN_NAM
    ------------------------------ ----------
    IDX_BRCODE BR_CODE
    IDX_BRCODE BANK_CODE
    IDX_BRCODE1 SYS_NC00082$

    IDX_BRCODE1 BANK_CODE

    user10698496 wrote:
    Once again great explanation in a way more easy to understand for beginners like me.

    Another question. If BANK_CODE is a nullable column, how will be the index with the constant "BR_CODE" (I want to say index ("BR_CODE", BANK_CODE)) help in select queries with BANK_ID in where clause?

    For example:-select col1 from bct where bank_id = 'x' and br_code = 'y '? -In this query will be how this constant index thanks to 'BR_CODE '? How does this index for this query?

    CBO will not use index (in normal case) when the indexed column is null. But you can create INDEXES of DATABASE FUNCTION and can for the use of this. In the structure of your query and index are different. Use of the index when the query predicate is match your index (without other intervention) structure. So for your query, it will not work.

  • How to create indexes of service according to

    Hi all

    I already post a thread associated with this thread, but there is little difference in the two threads.

    I had a query as below:

    Select concept_Un, raw_concept_a, relation_name, concept_b, discovered_relations raw_concept_b, where lower (concept_a) like '% of consumers' and lower (concept_a) like '% confidence % ';


    This query taking too long to run and its high rating.

    cost and execution time: 1155K and 03:51:11

    I changed above query using the Forum gurus, below query is changed:


    Select concept_Un, raw_concept_a, relation_name, concept_b, raw_concept_b

    of discovered_relations

    where regexp_instr (concept_Un, ' (consumer.*confidence) |) ((confidence.*Consumer))', 1, 1, 1, 'i') > 0;

    I created indexes for query modified as well:
    creating index SIDEV. IDX_reg_instr on SIDEV. DISCOVERED_RELATIONS (REGEXP_INSTR ("CONCEPT_A",'(consumer.*confidence) |)) (confidence.*Consumer))', 1, 1, 1, 'i'));

    After that the cost and time to get request reduces to:
    After optimization: 40001 and 08:01

    Now the question is whenever my request will vary as a condition, this means that search string can be vary to any value.

    So I need a basic index as function above is the index which can work for any string in the like operator, now my created index only works very well for the fixed string...

    Thank you

    Abbas85 wrote:

    Hi Chris,

    Thank you very much its working well, now, to reduce the cost and duration of execution, I used below queries as you suggest:

    create index idx_fulltext on discovered_relations (concept_a) indextype is ctxsys.context;

    Select * from discovered_relations

    where contains (concept_a, 'Confidence') > 0 and contains (concept_a, 'Consumer') > 0;

    Hello

    No, you didn't.

    The query I used was

    Select str

    of test_idx

    where

    contains (str, '% of the CONSUMPTION and CONFIDENCE %') > 0

    If you read carefully, you'll notice that I used already found lowercase uppercase searchwords.

    This works because the oracle text case insensitiv default you can read documentation:

    "By default, all text tokens are converted to uppercase and then indexed. This

    results in case-insensitive queries. For example, separate queries for each of

    the three words, CAT cat,

    "and Cat all return the same documents.

    Indexing with Oracle Text

    If you have more to use tiny but need to start to read the oracle text docs ;-)

  • Creating Index on another table in schema stored in my table

    Hello
    I want to create indexes on a table column that is in another schema of my schema and index will be stored in my diagram.

    ex: the current user 'hr '.
    SQL > create index idx1 on scott.emp (eno);

    Does the above query?

    Thank you
    Sri
    SQL> conn
    Enter user-name: hr@****
    Enter password:
    Connected.
    SQL> create index ndx on scott.emp(sal);
    
    Index created.
    
    SQL> show user
    USER is "HR"
    
    SQL> select index_name from user_indexes where index_name = 'NDX';
    
    INDEX_NAME
    ------------------------------
    NDX
    
  • appropriate using index for the execution of the parallel statement

    Hi all

    I created indexes for my table
    CREATE INDEX ZOO.rep184_med_arcdate ON ZOO.rep184_mediate(arcdate);
    That was before I started thinking about the execution of the parallel statement. As far as I've heard I need to change my correct use with parallel hint index. Could you please suggest the way forward?

    Marco wrote:
    Hi all

    I created indexes for my table

    CREATE INDEX ZOO.rep184_med_arcdate ON ZOO.rep184_mediate(arcdate);
    

    That was before I started thinking about the execution of the parallel statement. As far as I've heard I need to change my correct use with parallel hint index. Could you please suggest the way forward?

    When all else fails, read the Fine

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/sql_elements006.htm#autoId63

  • Index on the date column

    Hello

    I have a behavior when running a table with an indexed column date that seems a bit away from me.

    I have a table with many columns and rows 4.8 million (Oracle 11 g 2). One of his columns is of data type Date. This column is indexed using a b-three index.

    Consider the select statement. It returns only 32 thousand rows (less than 1% of the number of rows in the table). Oracle did a full scan to run the query.

    Field2 can be any column of the table that is not part of the index (for example, a column which is varchar2 (14)).

    As the used filter has a high selectivity, I expect Oracle to use the index on the date_field when executing the query. Have no idea about it? Is there a rule on the date columns indexing?

    Select Field2
    TABLE
    WHERE date_field > = TO_DATE('13/09/2010','DD/MM/YYYY')
    and date_field < TO_DATE('14/09/2010','DD/MM/YYYY')

    user492400 wrote:
    The clustering_factor is not too high?

    OBJECT_TYPE-> INDEX
    BLEVEL-> 2
    LEAF_BLOCKS-> 14796
    DISTINCT_KEYS-> 3249780
    AVG_LEAF_BLOCKS_PER_KEY-> 1
    AVG_DATA_BLOCKS_PER_KEY-> 1
    CLUSTERING_FACTOR-> 3620372
    NUM_ROWS-> 4823298

    If you look at your plan, it has a cost of 11156.

    The CBO estimated 29446 lines will be returned. It's a selectivity of 29446/4823298, which represents 0.61%.

    Therefore, the cost of using the index is approximately:

    2 (blevel) + 0.61% of the 14796 (pads of sheets) + 0.61% 3620372 (clustering factor) which is about 22195 (assuming that CBO based default settings).

    22195 is superior (so much) than 11156 so Full Table Scan WINS.

    See you soon

    Richard Foote
    http://richardfoote.WordPress.com/

  • Events of waiting "log file parallel write" / "log file sync", in CREATE INDEX

    Hello guys,.
    my current project I'm running a few tests of performance for oracle data guard. The question is "How LGWR SYNC transfer influence the performance of the system?"
    For the performance of the values, that I can compare I just built a normal oracle database in the first step.

    Now I perform various tests such as creating index 'broad', massive parallel inserts/validations, etc to get the marks.

    My database is an oracle 10.2.0.4 with multiplexed on AIX log files.

    I create an index on a table of "normal"... I have run "dbms_workload_repository.create_snapshot ()" before and after the CREATE INDEX for an equivalent period for the AWR report.
    Once the index is built (round about 9 GB), I made an awrrpt.sql for the AWR report.

    And now take a look at these values of the AWR
                                                                       Avg
                                                 %Time  Total Wait    wait     Waits
    Event                                 Waits  -outs    Time (s)    (ms)      /txn
    ---------------------------- -------------- ------ ----------- ------- ---------
    ......
    ......
    log file parallel write              10,019     .0         132      13      33.5
    log file sync                           293     .7           4      15       1.0
    ......
    ......
    How can it be possible?

    With regard to the documentation

    -> synchronization of log file: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/waitevents003.htm#sthref3120
    Wait Time: The wait time includes the writing of the log buffer and the post.
    -> log file parallel write: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/waitevents003.htm#sthref3104
    Wait Time: Time it takes for the I/Os to complete. Even though redo records are written in parallel, the parallel write is not complete until the last I/O is on disk.
    This was also my understanding... "log file sync" wait time should be higher than the 'parallel log writing' timeout, because of, it includes the e/s and the response time for the user's session.
    I could accept it, if the values are near each other (perhaps around 1 second about altogether)... but the difference between 132 and 4 seconds is too visible.

    Is the behavior of the log file sync/write different when you do a DOF as CREATE INDEX (maybe async... like you can influence it with COMMIT_WRITE initialization parameter?)?
    You have no idea how these values born?


    Ideas/thoughts are welcome.

    Thanks and greetings
  • Spatial index error while creating an index for a column GeoRaster

    Hi all

    Several months ago, I inserted 12 map PNG Raster files in Oracle as GeoRaster data. I then looked into MapBuilder to verify that they have been charged, and as they appear, it seems to suggest that they were.

    Today, however, I realized that I had not created an entry for USER_SDO_GEOM_METADATA or a spatial index. That's why I tried to do it by using the code below. When I made an entry in USER_SDO_GEOM_METADATA, I didn't add .spatialextent after the column name, web_raster_map. But while reading the manual MapViewer I decided that it was necessary to create a new entry. However, the error message displayed at the end, was the same in each case. If anyone has any ideas on what I can hurt, I would be grateful.

    Is the entries abscissa-x and the ordered is wrong? Should this be X and Y, and if that resolves the errors? I've been using a script I created previously to vector data and adapting.
    INSERT INTO USER_SDO_GEOM_METADATA
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'WEB_RASTER_MAP_FILE',
    'web_raster_map.spatialextent',
    SDO_DIM_ARRAY( -- full grid size goes here
    SDO_DIM_ELEMENT('eastings-x', -3273.58473839662, -8471.66, 0.005),
    SDO_DIM_ELEMENT('northings-y', -9694.76, -1632.88473839662, 0.005)),
    96163497); -- this is a user created srid
    commit;
    
    CREATE INDEX WEB_RASTER_MAP_FILE_IDX ON WEB_RASTER_MAP_FILE (web_raster_map)
       INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    commit;
    Error message was:
    Error starting at line 14 in command:
    CREATE INDEX WEB_RASTER_MAP_FILE_IDX ON WEB_RASTER_MAP_FILE (web_raster_map)
       INDEXTYPE IS MDSYS.SPATIAL_INDEX
    Error at Command Line:14 Column:13
    Error report:
    SQL Error: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13200: internal error [Unsupported Type] in spatial indexing.
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
    29855. 00000 -  "error occurred in the execution of ODCIINDEXCREATE routine"
    *Cause:    Failed to successfully execute the ODCIIndexCreate routine.
    *Action:   Check to see if the routine has been coded correctly.
    commit succeeded.
    Kind regards

    Tim

    Published by: user467357 on March 23, 2009 17:45
    To add an additional comment.

    Tim,
    You must create the index on web_raster_map.spatialextent.
    The create index must therefore:

    CREATE the INDEX WEB_RASTER_MAP_FILE_IDX ON WEB_RASTER_MAP_FILE (web_raster_map.spatial_extent)
    INDEXTYPE IS MDSYS. SPATIAL_INDEX;

  • How to create indexes on the ordered collection of XMLTYPE table?

    I use Oracle 11.2.0.2.

    Basically, my XML documents have a 3-level hierarchy:

    event

    + - action [1: n]

    + - param [1: n]

    I try to create indexes on the tables of the orderly collection, but cannot get the right syntax...

    I created a table with an XMLType object-relational column:

    CREATE TABLE T_C_RMP_MNTRNG_XML_FULL_IL4 (
      MESSAGE_ID NUMBER(22,0) NOT NULL ENABLE,
      XML_EVAL_ID NUMBER(22,0),
      VIN7 VARCHAR2(7 BYTE),
      FLEET_ID VARCHAR2(50 BYTE),
      CSC_SW_VERSION VARCHAR2(100 BYTE),
      RECEIVED DATE,
      XML_CONTENT SYS.XMLTYPE ,
      DWH_LM_TS_UTC DATE NOT NULL ENABLE,
      CONSTRAINT PK_C_RMP_MNTRNG_XML_FULL_IL4 PRIMARY KEY (MESSAGE_ID)
    ) NOLOGGING TABLESPACE CATALOG
    VARRAY "XML_CONTENT"."XMLDATA"."action" STORE AS TABLE "T_OR_MON_ACTION" (
      NOLOGGING TABLESPACE "CATALOG"
      VARRAY "param" STORE AS TABLE "T_OR_MON_ACTION_PARAM" (
      NOLOGGING TABLESPACE "CATALOG"
      ) RETURN AS LOCATOR
    ) RETURN AS LOCATOR
    XMLTYPE XML_CONTENT STORE AS OBJECT RELATIONAL XMLSCHEMA "http://mydomain.com/cs.xsd" ELEMENT "monitoring";
    
    
    
    
    

    I execute the SELECT statement:

    SELECT EVENT_ID, ACTION_SUB_ID, MESSAGE_ID, ACTION_TYPE, UNIXTS_TO_DATE(ACTION_TIMESTAMP) ACTION_TIMESTAMP
    FROM T_C_RMP_MNTRNG_XML_FULL_IL4, 
    XMLTABLE( 
      'for $i1 in /monitoring , 
      $i2 in $i1/action            
      return element r {              
      $i1/eventId,              
      $i2            
      }' 
      PASSING XML_CONTENT COLUMNS 
      EVENT_ID VARCHAR(40) PATH 'eventId', 
      ACTION_SUB_ID INTEGER PATH 'action/actionSubId', 
      ACTION_TYPE VARCHAR2(100) PATH 'action/type', 
      ACTION_TIMESTAMP NUMBER(13,0) PATH 'action/time' 
    ) T2 
    WHERE ( 
      EVENT_ID IS NOT NULL AND ACTION_SUB_ID IS NOT NULL 
    )
    
    
    
    
    

    The plan of the explain command looks like this (sorry, don't know how to get it formatted any 'eye-team'):

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

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

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

    |   0 | SELECT STATEMENT |                             |  1609K |  6316M |       |  6110K (1) | 20:22:11 |

    |*  1 |  HASH JOIN |                             |  1609K |  6316M |   111 M |  6110K (1) | 20:22:11 |

    |   2.   TABLE ACCESS FULL | T_C_RMP_MNTRNG_XML_FULL_IL4 |   582K |   104 M |       |  5241 (1) | 00:01:03 |

    |*  3 |   TABLE ACCESS FULL | T_OR_MON_ACTION |    32 M |   117G |       |   105K (2) | 00:21:08 |

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

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

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

    1 - access ("NESTED_TABLE_ID"= "T_C_RMP_MNTRNG_XML_FULL_IL4"." ("SYS_NC0001300014$")

    filter (CAST (SYS_XQ_UPKXML2SQL (SYS_XQEXVAL (SYS_XQEXTRACT ((SYS_XMLGEN ("T_C_RMP_MNTRN XMLCONCAT

    G_XML_FULL_IL4 ". "" $ SYS_NC00017 ", NULL, SYS_XMLCONV ("T_C_RMP_MNTRNG_XML_FULL_IL4". "SYS_NC00012$", 0.32,

    (('EC1EEF23FD023A27E04032A06D930A8D', 3, 3783, 1)), SYS_MAKEXML ('EC1EEF23FD023A27E04032A06D930A8D', 3780,

    'T_C_RMP_MNTRNG_XML_FULL_IL4 '. "' SYS_NC00008$ ', 'SYS_ALIAS_0 '. ((("' SYS_NC_ROWINFO$ ')),'/ ID ', NULL), 0,.

    0,20971520,0), 50.1, 2) AS VARCHAR (40)) IS NOT NULL)

    3 filter (CAST (TO_NUMBER (TO_CHAR ("SYS_ALIAS_0". "actionSubId")) AS INTEGER) IS NOT NULL) "

    Note

    -----

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

    -Construction detected no optimized XML (activate XMLOptimizationCheck for more information)

    The XML schema looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:storeVarrayAsTable="true" oraxdb:flags="2105639" oraxdb:schemaURL="http://mydomain.com/cs.xsd" oraxdb:schemaOwner="MYUSER" oraxdb:numProps="23">
      <xs:element name="monitoring" oraxdb:propNumber="3785" oraxdb:global="true" oraxdb:SQLName="monitoring" oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="monitoring757_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="action" oraxdb:propNumber="3780" oraxdb:global="false" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="action756_COLL" oraxdb:SQLCollSchema="MYUSER"/>
            <xs:element ref="reservationType" oraxdb:propNumber="3781" oraxdb:global="false" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="softwareVersion" oraxdb:propNumber="3782" oraxdb:global="false" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="eventId" oraxdb:propNumber="3783" oraxdb:global="false" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="vin" oraxdb:propNumber="3784" oraxdb:global="false" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="action" oraxdb:propNumber="3790" oraxdb:global="true" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="action754_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element ref="type" oraxdb:propNumber="3786" oraxdb:global="false" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element maxOccurs="unbounded" ref="param" oraxdb:propNumber="3787" oraxdb:global="false" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="param753_COLL" oraxdb:SQLCollSchema="MYUSER"/>
            <xs:element ref="actionSubId" oraxdb:propNumber="3788" oraxdb:global="false" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="time" oraxdb:propNumber="3789" oraxdb:global="false" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="type" type="xs:string" oraxdb:propNumber="3791" oraxdb:global="true" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="type751_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="param" oraxdb:propNumber="3794" oraxdb:global="true" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="param750_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element minOccurs="0" ref="value" oraxdb:propNumber="3792" oraxdb:global="false" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="key" oraxdb:propNumber="3793" oraxdb:global="false" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="value" type="xs:string" oraxdb:propNumber="3795" oraxdb:global="true" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="value748_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="key" type="xs:string" oraxdb:propNumber="3796" oraxdb:global="true" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="key747_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="actionSubId" type="xs:integer" oraxdb:propNumber="3797" oraxdb:global="true" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="actionSubId746_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="time" type="xs:integer" oraxdb:propNumber="3798" oraxdb:global="true" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="time745_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="reservationType" type="xs:string" oraxdb:propNumber="3799" oraxdb:global="true" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="reservationType744_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="softwareVersion" type="xs:string" oraxdb:propNumber="3800" oraxdb:global="true" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="softwareVersion743_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="eventId" type="xs:string" oraxdb:propNumber="3801" oraxdb:global="true" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="eventId742_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="vin" type="xs:string" oraxdb:propNumber="3802" oraxdb:global="true" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="vin741_TAB" oraxdb:defaultTableSchema="MYUSER"/>
    </xs:schema>
    
    
    
    
    

    How can I create an index on these tables of the ordered collection to improve performance?

    I found the example at http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb_rewrite.htm#ADXDB5859 but am not able to apply to this particular case...

    Thank you in advance...

    If the schema is not annotated and XS: Integer and XS: String are mapped to types of data NUMBER and VARCHAR2 (4000), so you must use in your query to avoid typecasting unnecessary operations.

    You must also use XMLTABLEs chained when accessing a parent/child instead of a FLWOR expression relationship, otherwise the CBO cannot rewrite the XQuery query correctly (maybe it's fixed in the latest version).

    If you make these changes, the plan should show the cleaner predicates:

    SQL > SELECT EVENT_ID, MESSAGE_ID, ACTION_TYPE, ACTION_SUB_ID, ACTION_TIMESTAMP

    2 FROM test_table

    3 XMLTABLE ('/ monitoring ')

    4 COLUMNS XML_CONTENT OF PASSAGE

    5 WAY of VARCHAR2 (4000) EVENT_ID "ID."

    6 actions for XMLTYPE PATH 'action '.

    (7) T1,

    8 XMLTABLE ('/ action')

    Shares of PASSAGE 9 COLUMNS

    NUMBER of ACTION_SUB_ID 10 PATH "actionSubId."

    11 PATH of VARCHAR2 (4000) ACTION_TYPE "type."

    12 WAY of NUMBER ACTION_TIMESTAMP 'time '.

    (13) T2

    14 WHERE EVENT_ID IS NOT NULL

    15 AND ACTION_SUB_ID IS NOT NULL

    16;

    Execution plan

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

    Hash value of plan: 1763884463

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

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

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

    |   0 | SELECT STATEMENT |                 |   109.   220K |     6 (17). 00:00:01 |

    |   1.  THE MERGE JOIN.                 |   109.   220K |     6 (17). 00:00:01 |

    |*  2 |   TABLE ACCESS BY INDEX ROWID | TEST_TABLE |    11.   352.     2 (0) | 00:00:01 |

    |   3.    INDEX SCAN FULL | SYS_C007567 |    11.       |     1 (0) | 00:00:01 |

    |*  4 |   JOIN TYPE.                 |   109.   216K |     4 (25) | 00:00:01 |

    |*  5 |    TABLE ACCESS FULL | T_OR_MON_ACTION |   106 S 216K |     3 (0) | 00:00:01 |

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

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

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

    2 - filter("TEST_TABLE".") (' SYS_NC00012$ ' IS NOT NULL)

    4 - access("SYS_ALIAS_0".") NESTED_TABLE_ID "=" TABLE_TEST. " ("' SYS_NC0000800009$ ')

    filter ("SYS_ALIAS_0". "NESTED_TABLE_ID"="TABLE_TEST" "." " ("SYS_NC0000800009$")

    5 - filter("SYS_ALIAS_0"." actionSubId» IS NOT NULL)

    Note

    -----

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

    Now, if it is still necessary, everything boils down to choosing a technique for index NULL values:

    -composite index with a column not zero or constant

    -FBI

    -bitmap image

    Choose the one that best fits your data, the selectivity and activity on the tables.

  • How to create indexes on the column xmtype

    Hello

    I have a table as follows

    CREATE TABLE T_TEST_XML (ID_PROCESSUS NUMBER, TXT_XML XMLTYPE);


    I query the table above very frequently with the query

    SELECT * FROM TXS T_TEST_XML WHERE EXISTSNODE (TXS. TXT_XML, '/ order [status = "PEN"]') = 1


    How to create function function index on the TXT_XML column for the xpath expression/order [status = "PEN"]' to improve the query performance?

    Thank you

    In fact if you are limited to the use of older software

    1 consider to define an XML schema and store XML using storage relational object.

    or

    2. If you need to store XML as CLOB to create the index on extractValue(), rather than existsNode() and provide the underlying value at the SQL level rather than the XPATH level.

    SQL> DROP TABLE T_TEST_XML
      2  /
    
    Table dropped.
    
    SQL> CREATE TABLE T_TEST_XML (PROCESS_ID NUMBER, TXT_XML XMLTYPE)
      2  /
    
    Table created.
    
    SQL> create INDEX T_TEXT_XML_IDX on T_TEST_XML( extractValue(TXT_XML,'/order/status'))
      2  /
    
    Index created.
    
    SQL> set autotrace on explain
    SQL> --
    SQL> SELECT *
      2    FROM T_TEST_XML TXS
      3   WHERE ExistsNode(TXT_XML,'/order[status="PEN"]') = 1
      4  /
    
    no rows selected
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3001212210
    
    ---------------------------------------------------------------------------------
    | Id  | Operation          | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |            |     1 |  2017 |    31   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS SEMI |            |     1 |  2017 |    31   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| T_TEST_XML |     1 |  2015 |     2   (0)| 00:00:01 |
    |*  3 |   XPATH EVALUATION |            |       |       |            |          |
    ---------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("P"."C_01$"='PEN')
    
    Note
    -----
       - dynamic sampling used for this statement (level=2)
    
    SQL> SELECT *
      2    FROM T_TEST_XML TXS
      3   WHERE extractValue(TXT_XML,'/order/status') = 'PEN'
      4  /
    
    no rows selected
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1430727070
    
    ----------------------------------------------------------------------------------------------
    | Id  | Operation                   | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |                |     1 |  2015 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_TEST_XML     |     1 |  2015 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | T_TEXT_XML_IDX |     1 |       |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access(EXTRACTVALUE(SYS_MAKEXML(0,"SYS_NC00003$"),'/order/status',null,0,0,5242
                  93,133120)='PEN')
    
    Note
    -----
       - dynamic sampling used for this statement (level=2)
    
    SQL>
    SQL>
    SQL>
    SQL>
    SQL>
    SQL>
    

    This allows the index press questioning on any status value, rather than just the PEN

  • create indexes on the upper part of the column - reminders function is not deterministic

    Hi all

    I'm having a problem on a database. When you create an index on an existing table on the upper part of a column, Oracle triggers an ORA-30553. I've done this 40 index other databases, with the same and different versions, without problem. When you create the index on a copy of the table, it is created with success...

    Here is the code:

    SQL > select * from v version $;

    BANNER

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

    Oracle Database 11 g Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for 64-bit Windows: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    SQL > CREATE INDEX IDX_SRE_E_MAIL_UPPER on fsynrelatie (upper (sre_e_mail)) tablespace idx;

    CREATE the INDEX IDX_SRE_E_MAIL_UPPER on idx tablespace fsynrelatie (upper (sre_e_mail))

    *

    ERROR on line 1:

    ORA-30553: the function is not deterministic

    SQL > create table fsynrelatie2 in select * from fsynrelatie;

    Table created.

    SQL > CREATE INDEX IDX_SRE_E_MAIL_UPPER on fsynrelatie2 (upper (sre_e_mail)) tablespace idx;

    The index is created.

    SQL > drop table fsynrelatie2;

    Deleted table.

    SQL > show parameter query_rewrite_enabled

    VALUE OF TYPE NAME

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

    query_rewrite_enabled string TRUE

    Hi all

    Thank you for the answers. I found the problem:

    On the table, there are 54 index:

    Select index_type, uniqueness, count (*) from user_indexes where table_name = 'FSYNRELATIE '.

    Index_type group, uniqueness

    INDEX_TYPE SINGLE CHARACTER COUNT (*)
    FIELD ARE NOT UNIQUE 1
    BASED ON A NORMAL FUNCTION ARE NOT UNIQUE 4
    NORMAL UNIQUE 3
    NORMAL ARE NOT UNIQUE 46

    3 unique indexes are the primary key and 2 another witch number field contains unique identifiers for rows in other systems. The domain index is an index of Oracle text on a couple of fields. There are 3 indices of function based on a high on a field and 1 on an individual function. This last clue has caused the problem. Apparently, on the creation, this function is deterministic, but when rolling a new version of the software. It became a non-deterministic function. When I delete the index, my original index on upper (sre_e_mail) has been created successfully! Now, I did the deterministic function again and could recreate the function without problem.

    Thanks for your comments!

Maybe you are looking for

  • Help, please! Try to remove tuneup helper of my iMac.

    I'm trying to remove my iMac tuneuphelper. I found most of the files and added to the trash. When I'm empty, I get a message "the operation cannot complete because the point help of tuneup is in use" I can't find an icon to exit the program. Activity

  • Pavilion p6710gr: ram upgrade

    Hey guys. So I wanted to update my ram and I bought this PATRIOT 4 GB PC3 10600 cl9 and I have a HP 4 GB 2RX8 DDR3 PC3-10600U. Now every time I connected (even a new one) my system wouldn't start why? I did something wrong?

  • path of the file myRIO USB

    I created a VI of for myRIO saved on a USB connected directly to myRIO of data acquisition. However, for some strange reason sometimes myRIO changes USB drive to say designation (sup / v: /) and recently V: / W:. I wonder what would cause myRIO behav

  • T500 to T540P migration

    I previously did a T500 OS system image and everything. The T500 is on it is the last step. I got a T540P as a replacement but I want to migrate the T500 Image system restore on my T540P. I know it's doable, because I did it BUT the problem is, I thi

  • Messages from blackBerry Smartphones

    It's a bit embarrassing to have a missed call appears on the icon on my phone and my messages icon. Is there a way to disable things to be sent to my General messages folder?