How to create indexes based for TO_CHAR function

I need to create an index of feature based for the to_char.when function I tried, I got an error, "only pure function can be indexed".which the error really means, help me in the creation of the index in order to reduce my query cost.

It works fine on my database. version 9iR2

create index IDX_TO_CHAR on emp(to_char(hiredate,'YYYY-MM-DD HH24:MI:SS'));

explain plan for
select hiredate from emp where to_char(hiredate,'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00:00:00';

---------------------------------------------------------------------------------
| Id  | Operation                   |  Name        | Rows  | Bytes | Cost (%CPU)|
---------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |              |     1 |     8 |     2  (50)|
|   1 |  TABLE ACCESS BY INDEX ROWID| EMP          |     1 |     8 |     2  (50)|
|*  2 |   INDEX RANGE SCAN          | IDX_TO_CHAR  |     1 |       |     2  (50)|
---------------------------------------------------------------------------------

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

   2 - access(TO_CHAR("EMP"."HIREDATE",'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00
              :00:00')

Your not seem to be a setting issue, then why not give us your sql and execution plan and so on.
There may be other ways to solve your sql as the creation of a function based index?

Tags: Database

Similar Questions

  • Invalidation of the index based on a function because the recompilation

    Hello

    one of our customers has two indices according to the functions that fall under the State "off" in some situations. After looking more closely at the situation, there are some things that my opinion are different from what I expected of a function-based index. Because I am unable to find anything about either on metalink (or I'm not asking the right question) I would appreciate a second opinion of you.

    To keep things simple, I gave an example to illustrate the behavior. I use Oracle 12.1.0.2, although it can also be reproduced on versions 10.2 and 11.2.

    It's my environment and three parameters that I find relevant to the discussion:

    SQL> select banner from v$version;
    
    BANNER
    ----------------------------------------------------------------------------
    
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    PL/SQL Release 12.1.0.2.0 - Production
    CORE    12.1.0.2.0      Production
    TNS for Linux: Version 12.1.0.2.0 - Production
    NLSRTL Version 12.1.0.2.0 - Production
    
    SQL> show parameter remote_dependencies
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ----------
    remote_dependencies_mode             string      TIMESTAMP
    
    SQL> show parameter query_rewrite
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- -------------
    query_rewrite_enabled                string      TRUE
    query_rewrite_integrity              string      enforced
    

    Test case:

    SQL> CREATE OR REPLACE FUNCTION f1 (p_string IN VARCHAR2)
      2  RETURN VARCHAR2
      3  DETERMINISTIC
      4  IS
      5  BEGIN
      6    RETURN lower(p_string);
      7  END f1;
      8  /
    
    Function created.
    
    SQL> CREATE TABLE tmp_t1 (a_string VARCHAR2(10));
    
    Table created.
    
    SQL> INSERT INTO tmp_t1 VALUES ('a');
    
    1 row created.
    
    SQL> COMMIT;
    
    Commit complete.
    
    SQL> CREATE INDEX x1_tmp_t1 ON tmp_t1(f1(a_string));
    
    Index created.
    
    SQL> set linesize 80;
    SQL> column index_name format a10;
    SQL> SELECT index_name, index_type, status, funcidx_status
      2    FROM user_indexes;
    
    INDEX_NAME INDEX_TYPE                  STATUS   FUNCIDX_
    ---------- --------------------------- -------- --------
    X1_TMP_T1  FUNCTION-BASED NORMAL       VALID    ENABLED
    

    We have our table and our based on an index function which basically converts the values to lowercase. From here on things, download a little weird. What happens with the index based on a function if the underlying function is recompiled? I always thought (and which is also stated in the Concepts and the use of function index (Doc ID 66277.1)) that the index would change its status to "disabled". Here is an excerpt of the said Doc ID:

    The index depends on the State of the PL/SQL function. The index can be

    struck down or rendered useless by changes to the function. The index is marked

    People with DISABILITIES, if he is brought to the function or function is re-created.

    The timestamp of the function is used to validate the index.

    To allow the index after it is created, the function if the signature of the

    the function is identical to the front:

    ALTER INDEX ENABLE;

    If the signature of functions is changed, to make the changes effective

    in the index, the index must be renewed to make it valid.

    ALTER INDEX REBUILD.

    It seems that this is not the case, as the index remains valid and activate.

    SQL> alter function f1 compile;
    
    Function altered.
    
    SQL> SELECT index_name, index_type, status, funcidx_status
      2    FROM user_indexes;
    
    INDEX_NAME INDEX_TYPE                  STATUS   FUNCIDX_
    ---------- --------------------------- -------- --------
    X1_TMP_T1  FUNCTION-BASED NORMAL       VALID    ENABLED
    

    OK, explicitly recompiling function F1 single timestamp changed. What if we replace the function completely and we change the output of the function - for example we will switch from a LOWER function to SUPERIOR function in the body of the F1. Again, it is change that I thought would be not only to disable the index based on a function, but also force its reconstruction. At least that is my understanding of the explanation in Doc ID).

    SQL> CREATE OR REPLACE FUNCTION f1 (p_string IN VARCHAR2)
      2  RETURN VARCHAR2
      3  DETERMINISTIC
      4  IS
      5  BEGIN
      6    RETURN UPPER(p_string);
      7  END f1;
      8  /
    
    Function created.
    
    SQL> SELECT index_name, index_type, status, funcidx_status
      2    FROM user_indexes;
    
    INDEX_NAME INDEX_TYPE                  STATUS   FUNCIDX_
    ---------- --------------------------- -------- --------
    X1_TMP_T1  FUNCTION-BASED NORMAL       VALID    ENABLED
    
    

    Should not be. Because of the function "create or replace" F1 never go through a "invalid" phase which may be necessary for index becomes unusable? What about queries on the TMP_T1 table? Does optimizer always uses access index or not? What about the results?

    SQL> EXPLAIN PLAN SET statement_id='s1' FOR
      2  SELECT a_string, f1(a_string) as f1_a_string, f1('a') as f1_literal
      3    FROM tmp_t1
      4   WHERE f1(a_string) = 'a';
    
    Explained.
    
    SQL> SELECT * from table(dbms_xplan.display(statement_id=>'s1'));
    
    PLAN_TABLE_OUTPUT                                                                                                   
    ------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 3133804460                                                                                         
                                                                                                                        
    -------------------------------------------------------------------------------------------------                   
    | Id  | Operation                           | Name      | Rows  | Bytes | Cost (%CPU)| Time     |                   
    -------------------------------------------------------------------------------------------------                   
    |   0 | SELECT STATEMENT                    |           |     1 |  2024 |     2   (0)| 00:00:01 |                   
    |   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TMP_T1    |     1 |  2024 |     2   (0)| 00:00:01 |                   
    |*  2 |   INDEX RANGE SCAN                  | X1_TMP_T1 |     1 |       |     1   (0)| 00:00:01 |                   
    -------------------------------------------------------------------------------------------------
    

    The index is used by the optimizer, see the results.

    SQL> column f1_a_string format a15;
    SQL> column f1_literal format a15;
    SQL> SELECT a_string, f1(a_string) as f1_a_string, f1('a') as f1_literal
      2    FROM tmp_t1
      3   WHERE f1(a_string) = 'a';
    
    A_STRING   F1_A_STRING     F1_LITERAL
    ---------- --------------- ---------------
    a          a               A
    

    A_STRING = value in the table

    F1_A_STRING = value of f1 (a_string) but the value is not evaluated because it comes from an index, so tiny value (remember, at the time index created the function returned small values)

    F1_LITERAL = value of the function f1 newly evaluated, using literal instead of the value in the table.

    Predicate f1 (a_string) = 'a' should return no rows because no character uppercase is equivalent to "a". Query with f1 (a_string) = 'A' should return a line, but it doesn't.

    SQL> SELECT a_string, f1(a_string) as f1_a_string, f1('a') as f1_literal
      2    FROM tmp_t1
      3   WHERE f1(a_string) = 'A';
    
    no rows selected
    

    Anyone know if this is an expected behavior? And, is it possible to disable the index based on a function whenever the underlying function signature is changed? The parameter query_rewrite_integrity = applied from

    DOC-ID 66277.1 does not seem to do the trick:

    (c) session variables

    ~~~~~~~~~~~~~~~~~~~~

    QUERY_REWRITE_ENABLED (true, false),

    QUERY_REWRITE_INTEGRITY (confidence, forced, stale_tolerated)

    determines the optimizer to use index based on a function with

    expressions using SQL, user defined functions functions.

    TRUST: Oracle allows rewrites using relationships that have

    was declared.

    APPLIED: Oracle ensures and guarantees consistency and integrity.

    STALE_TOLERATED: Oracle allows rewrites using vessels of the relationship not applied.

    Used in the case of materialized views.

    Set session variable cost function optimizer to choose the

    a function-based index

    Kind regards

    SAMO

    From the Manual 11.2 ( https://docs.oracle.com/cd/E11882_01/appdev.112/e41502/adfns_indexes.htm#ADFNS254 )

    "If you change the semantics of a DETERMINISTIC run and recompile, then you must manually rebuild all addicts depending on index and materialized views." Otherwise, they report results for the previous version of the function. »

    This note is not that I made my initial comment well - which was based on an incorrect memory the relationship between function-oriented and autonomous pl/sql functions, so I won't try to explain it. In fact, I went back to Oracle 8i practice to see if something had changed between yesterday and today and found that I had described exactly the behavior that the OP has been seeing. It's the way it is supposed to be.

    Concerning

    Jonathan Lewis

  • How to create unique variables for... in loop? (AS2)

    Hello

    I have a function onEnterFrame controlling all the movie clips in a table. The movement of each of these clips is controlled by a few variables - speed, acceleration, etc - that are changed on every enterFrame. I can't understand how to create unique variables for each element of the array. Now my variables are the same for all elements, and therefore the proposals of each video clip are the same.

    I used this code to add my video clips in the table:

    for (i = 0; i < starNumber; i ++) {}
    duplicateMovieClip (star, "star" + I, i);
    starArray.push (this ["star" + String (i)]);
    }

    I do a similar thing to create unique variables for each? Or is there something I need to do my loop (myClip in myArray) which is contained in my onEnterFrame function?

    I can post my code if that would help (65 lines).

    Creating unique variables is easy way out. Here's the modified code using unique variables that should solve your problem:

    var i: Number;

    var starArray:Array = [];

    var starArray_X:Array = [];

    var starArray_Y:Array = [];

    var mc:String;

    var scale: number;

    var speedXMod:Number;

    var speedYMod:Number;

    var starNumber:Number = 10;

    var minSize:Number = 15;

    var maxSize:Number = 80;

    var speed: number = 0.2;

    var minSpeed:Number = 0;

    var maxSpeed:Number = 1;

    for (i = 0; i< starnumber;="">

    duplicateMovieClip (star, "star" + I, i);

    starArray.push (this ["star" + String (i)]);

    }

    (MC starArray) {}

    starArray [mc] ._x = (Math.Random () * Stage.width);

    starArray [mc] ._y = (Math.Random () * Stage.height);

    scale = (minSize + (Math.Random () * (maxSize - minSize)));

    ._xscale starArray [mc] = scale;

    starArray [mc] ._yscale = scale;

    var startSpeedX:Number = ((Math.pow (-1, (Math.round (Math.random ())) * (minSpeed + (Math.Random () * (maxSpeed - minSpeed)));)))

    var startSpeedY:Number = ((Math.pow (-1, (Math.round (Math.random ())) * (minSpeed + (Math.Random () * (maxSpeed - minSpeed)));)))

    [mc] starArray_X = startSpeedX;

    [mc] starArray_Y = startSpeedY;

    onEnterFrame = function() {}

    (MC starArray) {}

    speedXMod = ((Math.random () * acceleration)-(0,5 * accélération));

    speedYMod = ((Math.random () * acceleration)-(0,5 * accélération));

    If (((Math.abs (starArray_X [mc] + speedXMod)) < maxspeed)="" &&="" ((math.abs(stararray_x[mc]="" +="" speedxmod))=""> minSpeed)) {}

    [mc] starArray_X += speedXMod;

    } else {}

    [mc] starArray_X = speedXMod;

    }

    If (((Math.abs (starArray_Y [mc] + speedYMod)) < maxspeed)="" &&="" ((math.abs(stararray_y[mc]+="" speedymod))=""> minSpeed)) {}

    [mc] starArray_Y += speedYMod;

    } else {}

    [mc] starArray_Y = speedYMod;

    }

    If (((starArray [mc]._x + starArray_X[mc]) > 0) & ((starArray [mc]._x + starArray_X[mc])))<>

    starArray [mc] ._x += starArray_X [mc];

    } else {}

    starArray_X [mc] * = - 1;

    starArray [mc] ._x += starArray_X [mc];

    }

    If (((starArray [mc]._y + starArray_Y[mc]) > 0) & ((starArray [mc]._y + starArray_Y[mc])))<>

    starArray [mc] ._y += starArray_Y [mc];

    } else {}

    starArray_Y [mc] * = - 1;

    starArray [mc] ._y += starArray_Y [mc];

    }

    }

    }

    }

  • How to create an ERD for the vista sp2 x 64?

    How to create an ERD for the vista sp2 x 64?

    How to create an ERD for the vista sp2 x 64?

    If you do not have a Microsoft Vista DVD, make a repair disc to do a Startup Repair:

    Download the ISO on the link provided and make a record of repair time it starts.

    Go to your Bios/Setup, or the Boot Menu at startup and change the Boot order to make the DVD/CD drive 1st in the boot order, then reboot with the disk in the drive.

    At the startup/power on you should see at the bottom of the screen either F2 or DELETE, go to Setup/Bios or F12 for the Boot Menu.

    When you have changed that, insert the Bootable disk you did in the drive and reboot.

    http://www.bleepingcomputer.com/tutorials/tutorial148.html

    Link above shows what the process looks like and a manual, it load the repair options.

    NeoSmart containing the content of the Windows Vista DVD 'Recovery Centre', as we refer to him. It cannot be used to install or reinstall Windows Vista, and is just a Windows PE interface to recovering your PC. Technically, we could re-create this installation with downloadable media media freely from Microsoft (namely the Microsoft WAIK, several gigabyte download); but it is pretty darn decent of Microsoft to present Windows users who might not be able to create such a thing on their own.

    Read all the info on the website on how to create and use:

    http://NeoSmart.net/blog/2008/Windows-Vista-recovery-disc-download/

    ISO Burner: http://www.snapfiles.com/get/active-isoburner.html

    It's a very good Vista startup repair disk.

    You can do a system restart tool, system, etc it restore.

    It is NOT a disc of resettlement.

    Make sure you get the 64 bit version.

    See you soon. Mick Murphy - Microsoft partner

  • How to create a password for the user account for my child?

    How to create a password for the user account for my child?

    You can create the user with the parental control account. This will act as a protection for the child's account.

    You can take a look at the following links on setting up parental controls:

    http://Windows.Microsoft.com/en-us/Windows/set-up-family-safety#set-up-family-safety=Windows-7

    http://Windows.Microsoft.com/en-us/Windows/set-parental-controls#1TC=Windows-7

    http://www.howtogeek.com/HOWTO/10524/how-to-use-parental-controls-in-Windows-7/

  • How to create the ADC for first name

    Hello

    I have the situation here, I need display the default in the e-mail (Dear) when the value in the first name field is less than 2 characters long or it is empty. Otherwise, I need to insert the value of the field name (Dear John).

    Please let me know how to create an ADC for this.

    Thank you

    Rama

    Use wildcards for searching.

    ? = any 1 character

    * = 0 or any number of characters

    In order to find people with more than 2 characters in this area?: *

    Then, build your default rule to merge the content in case they encounter more rule of character 2.

  • How to create a shortcut for all users during installation

    Hi people,

    We have a desktop application that is distributed with Java Webstart and works on Win7 machines. Initially, users all connected using a connection by default, so creating shortcuts was not a problem. Now, because of new networking strategies, each user has his own connection.

    The problem is that the shortcut to the application is created in the user profile (for example "C:\Users\JohnDoe\", so that other users in the same machine can not run the application unless he or she installs the application again.)

    Is there a way to create this shortcut for all users using JNLP API or configuration in the xml file?

    If anyone has need of the solution: during installation I save the jnlp file in a directory accessible to all the world and then start the application using "javaws path\to\file.jnlp". More details in How to create a shortcut for java webstart available for all users on Windows 7?-stack overflow

  • How to create a password for the pdf file

    The Adore Acrobat XI, how to create a password for the file? Aid says going to the Tools Menu and clicking on the Protection tab - but there is no option. In the security file - properties - screen, it shows the security details but doesn't allow for no change.

    I think you can be mixing two different products: (free) Adobe Reader and Acrobat ($$).

  • How to create a card for After Effects?

    How to create a card for After Effects?

    After effects Developer Center

  • How to create the presentation for the columns variable and use it in the story?

    Hi all

    Someone knows how to create variable presentation for a column (that is, I need to create it in edit section formula itself). And then, I should use it in the Narrative section to display the value of this column. Is this possible? Or do I need to use any other variable for this requirement? If Yes please let me know, how to create it? This is a very urgent requirement.

    Thanks in advance
    Stephanie

    Hello
    You can have any number of columns in the narrative view, he will accept... Just mention the numbers of the columns in the view body narrative...

    check if useful/correct...

    Thank you
    prassu

  • How to create a jar for icons

    Hi all


    How to create a jar for icons? Please help me thanks in advance.


    Sarah

    Hi Sarah!

    To do this, you use at best the jdk (java development kit) which is already
    installed on your pc in forms is installed.

    Copy all your gif icons in a folder
    Open the command prompt and in this folder.

    If we assume that you have installed forms in the default directory, call the jar.exe like this:

     x:\DevSuiteHome_1\jdk\bin\jar -cfv your_icons.jar *.gif
    

    This will create a jar file in the same directory.
    Copy the jar file into your x:\DevSuiteHome_1\forms\java folder.

    Then open your formsweb.cfg x:\DevSuiteHome_1\forms\server and change your configuration entry under the

    archive_jini=frmall_jinit.jar
    

    TO

    archive_jini=frmall_jinit.jar, your_icons.jar
    

    Please check if in your formsweb.cfg so the imagebase is set to the code base.
    If this isn't the case, create a parameter in your config entry:

    imagebase=codebase
    

    Now the jar file is loaded when you start your application and the icons are
    turns red from the jar file.

    Concerning

  • How to create a login for PHP users

    How to create a login for users to access their data, currently, I don't see the first user each time I connect with a different user name. I know that I need session stuff but don't know how to use, add or where to put them.
    Thanks in advance.

    Hello

    Find this in your login page:

    session_register ("MM_Username");

    and then you add a session variable in MX called it:

    MM_Username

    then on any of your pages that calls the base to make sure that you use the = MM_Username and then you're all set; Make sure that the tables have a field to reference the session MM_Username variable.

    See you soon
    Let me know if you just come!

  • How Oracle called the hidden for the function-based index columns?


    I came across an interesting problem today.  Statistics object for a schema that have been created on the basis of data X have been imported into a 'identical' to the database schema Y.

    The problem is that, on the basis of data X a group of hidden columns associated with index based service (FBIs) were named SYS_NC00182$ to SYS_NC00191$ and on the basis of data Y the same hidden columns were named SYS_NC00183$ to SYS_NC00192$!  The consequence was that statistical column for an FBI data base X have been used for a totally different FBI on the database Y.

    Now, of course, if this was g 11 or 12 c I could just create virtual columns and those of the index.  In this way the names of the columns would be compatible on databases.  However, it is a 10g database, and I do not have this option.

    I am curious to understand how Oracle generates these hidden column names.  I'm also curious if, in 10g, there is a way to identify the name of a column hidden for an FBI that doesn't involve a statement explain plan running on a query that uses all the expressions of the FBI for the table.

    The names of $ SYS_NCnnnnn are based on the internal column id - what is loosely based on the order of creation of the FBI. If you delete a column the column internal ids (after this column), which means the names for the SYS_NCnnnnn$ the change.  An opportunity to explain your results is that a (real) column on the X data table fell, but the column still exists on the database Y.

    If you want to get the link between the current internal name and expression, then you can start with dba_ind_expressions - and create a customized version of the view - e.g @.

    Select c.intcol #, c.name, io.name, idx.name, bo.name, base.name, c.default$, ic.pos #.

    of sys.col$ c, sys.obj$ idx, basis of sys.obj$, sys.icol$ ic.

    sys. User$ io, sys.user$ bo, sys.ind$ I

    where bitand(ic.spare1,1) = 1 / * expression * /.

    and (bitand (students, 1024) = 0) / * not bmji * /.

    and ic.bo # c.obj = #.

    and ic.intcol # c.intcol = #.

    and ic.bo # base.obj = #.

    and io.user # idx.owner = #.

    and bo.user # base.owner = #.

    and ic.obj # idx.obj = #.

    and idx.obj # i.obj = #.

    and however # (1, 2, 3, 4, 6, 7, 9)

    /

    The first two columns in the select ones that I added to the initial view definition.

    Concerning

    Jonathan Lewis

  • 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

Maybe you are looking for