At which column i will create index ????

my query is as follows and please tell me at which column of the table i would create an index
select code, detail, nvl(sum(dr)-sum(cr),0) from spda
where sdate < '01-feb-09'
order by codebecause the query result very slow as there is above 3 million record in a table
Regards
M. Laeeque A.
Edited by: MLA on Feb 27, 2009 12:02 PM

MLA wrote:
my query is as follows and please tell me at which column of the table i would create an index
select code, detail, nvl(sum(dr)-sum(cr),0) from spda
where and sdate < '01-feb-09'because the query result very slow as there is above 3 million record in a tableYou've posted this request three times (with three different versions of above statement).
Which one would you like to get replied to?
If this is the nested subquery that is part of the query posted here: Query Response Very Slow
you should consider that the nested subquery is correlated to the outer query by this additional predicate:
WHERE  SUBSTR(spda.mcode,1,2) || '-' || SUBSTR(spda.mcode,3,4) =
                SUBSTR(ac.code,1,2)    || '-' || SUBSTR(ac.code,3,4)So in order to optimize the nested subquery access path this should be taken into account.
As I've already pointed out in the other thread, getting rid of the nested subquery and instead using regular joins probably offers the best performance.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/

Similar Messages

  • In cloud when i create VM on which host VM will create?

    I have Host group in that i moved two host's but when i created VM it created in 1 host but can i select which VM should create in which HOST?
    Santosh Dharamsale

    I am not sure that I follow you on this one.
    When you deploy a VM to a cloud, it can be placed to any of the hosts available in the host groups you have added to this cloud.
    Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com )

  • How to choose the index on which column?

    Hi
    i have a doubt while creating index for the table which is not having index. how to choose index on which column it will be beneficial ?
    i heard from num_rows from dba_tables and some other view to calculate but i m not sure. with the help of that view we can see how much columns is used more freq on which column we have to create index rather than just checking in query on where condition and full table scan? pls help me out to decide the index creation on basis.
    Thanks..

    In my opinion, there's no shortcut to knowing your queries, how the table is going to be accessed and what proportion of the rows various queries will access.
    There are tuning advisors which will recommend some indexes if you run a workload.
    Edited by: dombrooks on Oct 10, 2009 12:43 PM

  • I can not create index

    Hello,
    I am using 8.1.7
    I'd like to create index on clob column, but after:
    create index news_ctx_ind on news(news_description) indextype is CTXSYS.CONTEXT parameters ('DATASTORE CTXSYS.DEFAULT_DATASTORE')
    i get:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-20000: interMedia Text error:
    DRG-11422: linguistic initialization failed
    DRG-00100: internal error, arguments : [52100],[drxs.c],[553],[gxtopen],[1]
    DRG-11432: file error while accessing interMedia Text knowledge base
    ORA-06512: at "CTXSYS.DRUE", line 126
    ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 78
    ORA-06512: at line 1
    please help me.
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Omar Alonso ([email protected]):
    Do you have russian content in the documents?
    What's the db version and character set?
    You may try to disable the theme indexing:
    begin
    ctx_ddl.create_preference('mylex','BASIC_LEXER');
    ctx_ddl.set_attribute('mylex','index_themes','NO');
    ctx_ddl.set_attribute('mylex','index_text','YES');
    end;
    create index myindex on mytable(docs) indextype is ctxsys.context parameters('LEXER lmylex');<HR></BLOCKQUOTE>
    Hi,
    I am also facing the same problem. my character set is default and i am using oracle 8.1.6. I can create index if my database is dedicated but it will not work for mts for same table and data using intermedia.
    Suppose i dont want to disable theme indexing and though i want to create index then what i have to do.
    null

  • Creating Indexes within an XMLType column

    Hi,
    I have following XML document stored as XMLType column,
    <ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus"><status><statusCode>934</statusCode><statusDate>Wed Apr 07 16:05:53 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>934</statusCode><statusDate>Wed Apr 07 15:58:25 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>934</statusCode><statusDate>Wed Apr 07 15:54:02 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>750</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Document Metadata 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 LTC</comment></status><status><statusCode>932</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Loaded to Novus</comment></status><status><statusCode>700</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Document is deleted from OCA.</comment></status></ocaStatus>
    I created following Indexes within the XML,
    CREATE INDEX "OCA_DEV"."OCA_STATUS_CODE_INDEX" ON "OCA_DEV"."DOCUMENT_STATUS_XML" (EXTRACTVALUE('/ocaStatus/status/statusCode'));
    CREATE 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 multiple status within each XML which violates the Indexing.
    Is there any way I can still create the Indexes allowing multiple status values in each XML?
    Thanks in advance.

    Hi,
    You may want to store your document as a schema-based, object-relational XMLType to achieve that.
    Then you'll be able to create indexes on the nested table used to store each "status" element.
    Here's an example based on your sample document.
    1) First, create and register a schema. The following is basic but sufficient here, let's call it "ocastatus.xsd" :
    <?xml version="1.0"?>
    <xsd:schema
    targetNamespace="http://xmlbeans.apache.org/ocastatus"
    xmlns="http://xmlbeans.apache.org/ocastatus"
    elementFormDefault="qualified"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb">
    <xsd:element name="ocaStatus" type="OCASTATUS_TYPEType"/>
    <xsd:complexType name="OCASTATUS_TYPEType" xdb:SQLType="OCASTATUS_TYPE">
      <xsd:sequence>
       <xsd:element name="status" type="STATUS_TYPEType" xdb:SQLName="status" maxOccurs="unbounded" xdb:SQLCollType="STATUS_V"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="STATUS_TYPEType" xdb:SQLType="STATUS_TYPE">
      <xsd:sequence>
       <xsd:element name="statusCode" type="xsd:double" xdb:SQLName="statusCode" xdb:SQLType="NUMBER"/>
       <xsd:element name="statusDate" xdb:SQLName="statusDate" xdb:SQLType="VARCHAR2">
        <xsd:simpleType>
         <xsd:restriction base="xsd:string">
          <xsd:maxLength value="50"/>
         </xsd:restriction>
        </xsd:simpleType>
       </xsd:element>
       <xsd:element name="userId" xdb:SQLName="userId" xdb:SQLType="VARCHAR2">
        <xsd:simpleType>
         <xsd:restriction base="xsd:string">
          <xsd:maxLength value="50"/>
         </xsd:restriction>
        </xsd:simpleType>
       </xsd:element>
       <xsd:element name="comment" xdb:SQLName="comment" xdb:SQLType="VARCHAR2">
        <xsd:simpleType>
         <xsd:restriction base="xsd:string">
          <xsd:maxLength value="100"/>
         </xsd:restriction>
        </xsd:simpleType>
       </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>Registering...
    BEGIN
    dbms_xmlschema.registerSchema(
      schemaURL => 'ocastatus.xsd',
      schemaDoc => xmltype(bfilename('XSD_DIR','ocastatus.xsd'), nls_charset_id('AL32UTF8')),
      genTypes => true,
      genTables => false
    END;2) Table definition :
    CREATE TABLE oca_status (
      num NUMBER,
      doc XMLTYPE
      XMLTYPE doc STORE AS OBJECT RELATIONAL
       XMLSCHEMA "ocastatus.xsd"
       ELEMENT "ocaStatus"
       VARRAY doc.xmldata."status" STORE AS TABLE oca_status_tab
    CREATE INDEX oca_status_tab_idx1 ON oca_status_tab("statusCode");
    CREATE INDEX oca_status_tab_idx2 ON oca_status_tab("statusDate");3) Inserting document...
    INSERT INTO oca_status (num, doc)
    VALUES(1, xmltype('<ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus">
      <status>
        <statusCode>934</statusCode>
        <statusDate>Wed Apr 07 16:05:53 GMT+05:30 2010</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>934</statusCode>
        <statusDate>Wed Apr 07 15:58:25 GMT+05:30 2010</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>934</statusCode>
        <statusDate>Wed Apr 07 15:54:02 GMT+05:30 2010</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>750</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Document Metadata 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 LTC</comment>
      </status>
      <status>
        <statusCode>932</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Loaded to Novus</comment>
      </status>
      <status>
        <statusCode>700</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Document is deleted from OCA.</comment>
      </status>
    </ocaStatus>')
    );Verifying index use (XPath rewrite) ...
    SQL> EXPLAIN PLAN FOR
      2  SELECT * from oca_status x
      3  WHERE existsnode(x.doc, '//status[statusCode="934"]') = 1;
    Explicité.
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1840289382
    | Id  | Operation                     | Name                | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                     |     1 |  7938 |     4  (25)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL            | OCA_STATUS_TAB      |     1 |  2145 |     4   (0)| 00:00:01 |
    |   2 |  NESTED LOOPS                 |                     |     1 |  7938 |     4  (25)| 00:00:01 |
    |   3 |   SORT UNIQUE                 |                     |     4 |  8580 |     2   (0)| 00:00:01 |
    |   4 |    TABLE ACCESS BY INDEX ROWID| OCA_STATUS_TAB      |     4 |  8580 |     2   (0)| 00:00:01 |
    |*  5 |     INDEX RANGE SCAN          | OCA_STATUS_TAB_IDX1 |     4 |       |     1   (0)| 00:00:01 |
    |   6 |   TABLE ACCESS BY INDEX ROWID | OCA_STATUS          |     1 |  5793 |     1   (0)| 00:00:01 |
    |*  7 |    INDEX UNIQUE SCAN          | SYS_C00243981       |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("NESTED_TABLE_ID"=:B1)
       5 - access("statusCode"=934)
       7 - access("NESTED_TABLE_ID"="X"."SYS_NC0000900010$")
    Note
       - dynamic sampling used for this statement
    25 ligne(s) sélectionnée(s).
    SQL> Regards.

  • CREATE INDEX WITH DUPLICATE COLUMN NAME

    Hi,
    i need to interface our application with an Orale Bridge to CREATE INDEX with duplcate column Name.
    For Example
    CREATE index NLOT_FOURNLOT_idx ON NLOT(FOURNISSEUR ,NOLOT ,FOURNISSEUR ,NOBLFOUNISSEUR,NOLIGNEBL ,NOLOT ,QTECOLISRECUES ,CODENONQUALITE ,QTECOLISACCEPTE);
    CREATE table NLOT(
    FOURNISSEUR VARCHAR2(09)
    ,NOBLFOURNISSEUR VARCHAR2(13)
    ,NOLIGNEBL VARCHAR2(03)
    ,NOLOT VARCHAR2(20)
    ,QTECOLISRECUES VARCHAR2(10)
    ,CODENONQUALITE VARCHAR2(02)
    ,QTECOLISACCEPTE VARCHAR2(10)
    ,NOMBREDECOLISRE VARCHAR2(10)
    ,NOMBREDECOLISAC VARCHAR2(10)
    ,FILLER VARCHAR2(1)
    ,FILLE1 VARCHAR2(1)
    ,TYPEREFERENCE VARCHAR2(01)
    ,REFERENC1 VARCHAR2(15)
    ,CONTROLERECEPTI VARCHAR2(01)
    ,DATEDEPEREMPTIO VARCHAR2(8)
    ,CONTROLEPROCHAI VARCHAR2(1)
    Thanks
    Philippe

    Well, you can't do it. ORA-957 is one of those irrevocable errors for which the solution is to remove the duplicate name from the SQL statement.
    But, anyway, why do you want to do this? I would guess there's no performance benefit from having the same column indexed twice (of course it's impossible to test this, so it's just my opinion).
    Cheers, APC

  • ORA-01450 when trying to create index on xmltype column

    Hi,
    I have a table that contains an xmltype column. It is a schema-based column and uses object-relational structured storage. When I tried to create an index like:
    create index ssual_sipuser_idx on ssua_line (extractValue(ssual_configuration, '/ssuaLineApplication/sipUser'));
    I got the following:
    ORA-01450: maximum key length (3118) exceeded
    The sipUser tag is of string type. I have also tried creating the index on the extract function.
    create index ssual_sipuser_idx on ssua_line (ssual_configuration.extract('/ssuaLineApplication/sipUser/text()').getStringVal())
    Gave me the same error message. My database block size is 4k. This is Oracle 9.2.0.4 running on Solaris.
    Any help will be appreciated.
    Thanks,
    Gloria

    Thanks for the reply, Coby.
    My field is really small, probably around 10 bytes. Actually I've been testing on two servers, a 9201 and a 9204. I know that Oracle doesn't support XML DB on 9201 anymore but our company hasn't switched over yet. Anyways, here's really what I saw:
    9201
    - creating an index with extractValue() or extract() doesn't work
    9204
    - extractValue() works
    - extract() still doesn't work
    Now I'm using the substr() workaround. I should also mention that extractValue() with a numeric field works (using getNumberVal()).
    I wonder if specifying the field length in the XML Schema would make a difference. I may try that next.

  • How to create  index for a column of a view

    Hi,
    I have created view for a table and then i am trying to create index for a column of that view. i am using the query "CREATE INDEX index_name ON view_name (col)". but Mysql is showing error like "view_name is not a base table".
    How can i do that......

    As mentioned this is a java forum not a mysql forum, but as I know the answer - you can't create an index directly on a view in mysql.

  • How to create index on a xmltype column stored as CLOB

    actually i have two problems.
    i uploaded this schemaA.xsd file into xmldb repository without problems. registration also went ok.
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    schemaURL => 'http://xmlns.example.com/xdb/documentation/schemaA.xsd'
    ,schemaDoc => sys.UriFactory.getUri('/home/dev/schemaA.xsd')
    ,local => TRUE
    ,genBean => false
    ,genTypes => TRUE
    ,genTables => false
    ,enableHierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
    END;
    then i run this:
    create table pf_table_a(
         id VARCHAR2(100) primary key,
         xsd VARCHAR2(3000),
    xml_document XMLType
    ) XMLTYPE COLUMN xml_document
    STORE AS CLOB
    XMLSCHEMA "http://xmlns.example.com/xdb/documentation/schemaA.xsd"
    ELEMENT "order";
    and got this error:
    SQL> @d:\usr\dev\perftest\create_tables.sql
    Table created.
    create table pf_table_a(
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    anyway the table was created. so i went on to create indexes.
    SQL> create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@or
    derNo'));
    create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@orderNo
    ERROR at line 1:
    ORA-04063: table "BAUSER1.PF_TABLE_A" has errors
    this of course is wrong. because the command is for creating index of a XMLTYPE table. no a column. but what is the correct command? thanks.
    jack.

    actually i have two problems.
    i uploaded this schemaA.xsd file into xmldb repository without problems. registration also went ok.
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    schemaURL => 'http://xmlns.example.com/xdb/documentation/schemaA.xsd'
    ,schemaDoc => sys.UriFactory.getUri('/home/dev/schemaA.xsd')
    ,local => TRUE
    ,genBean => false
    ,genTypes => TRUE
    ,genTables => false
    ,enableHierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
    END;
    then i run this:
    create table pf_table_a(
         id VARCHAR2(100) primary key,
         xsd VARCHAR2(3000),
    xml_document XMLType
    ) XMLTYPE COLUMN xml_document
    STORE AS CLOB
    XMLSCHEMA "http://xmlns.example.com/xdb/documentation/schemaA.xsd"
    ELEMENT "order";
    and got this error:
    SQL> @d:\usr\dev\perftest\create_tables.sql
    Table created.
    create table pf_table_a(
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    anyway the table was created. so i went on to create indexes.
    SQL> create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@or
    derNo'));
    create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@orderNo
    ERROR at line 1:
    ORA-04063: table "BAUSER1.PF_TABLE_A" has errors
    this of course is wrong. because the command is for creating index of a XMLTYPE table. no a column. but what is the correct command? thanks.
    jack.

  • How to create index on xmtype column

    Hi,
    I have a table as follows
    CREATE TABLE T_TEST_XML (PROCESS_ID NUMBER, TXT_XML XMLTYPE);
    I query the above table very frequently with the query
    SELECT * FROM T_TEST_XML TXS WHERE EXISTSNODE(TXS.TXT_XML, '/order[status="PEN"]') = 1
    How to create function based index on the TXT_XML column for the xpath expression /order[status="PEN"]' to improve the query performance?
    Thank you

    Actually if you are limited to using older software
    1. Consider defining an XML Schema and storing the XML using object relational storage.
    or
    2. If you must store the XML as CLOB create the index on extractValue(), rather than existsNode() and supply the predicate 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 to support querying on any value of status, rather than just PEN

  • Do I need to create indexes on column name?

    Following queries have been shown as bad sql :          
    select * from t1 where name = 'FUNCTION'
    Count=     7     Avg Time=13     Min Time=0     Max Time=47
    select * from t2 where name = 'USER_TYPE'      
    Count=2     Avg Time=85     Min Time=0     Max Time=156
    select * from t3 where name = 'TEMPLATE'
    Count=7     Avg Time=19     Min Time=0     Max Time=32
    All these tables have less than 20 records and static tables.                    
    Do I need to create indexes on column name?

    A FTS even on very small tables can require more latches than accessing via an index. Also, a table access requires the segment header and data block to be accessed (2) whereas an index on a small index only requires access to the index root block and table block (2).
    True, it's unlikely to make much of a difference in most environments but if the table is really heavily accessed, indexing even very small tables can help to reduce the related latch overheads.
    Most of these small tables have PKs and are accessed via the PK so associated indexes usually exist anyways.
    Cheers
    Richard Foote
    http://richardfoote.wordpress.com/

  • How to create index on xmltype column

    I have a table having only one column xmlcontent (xmltype). This table stores xml data of about 10GB size. I'm using extract value to move the data to staging tables.
    How can I create index on xmltype column?
    Create index indexname on table (column) doesn't seem to work.
    Sample xmlstructure is given below
    <Root>
    <Type>Insert</Type>
    <Date>2006-12-29</Date>
    <Source>8</Source>
    <id>data</id>
    <key_flds>
    <fld><id>Key1</id><val>C</val></fld>
    <fld><id>Key2</id><val>429672</val></fld>
    <fld><id>Key3</id><val>8</val></fld>
    </key_flds>
    </Root>
    I need to do extract value on all tags and move them to corresponding relational tables.

    Hi, you need to create them using something like this (what I have used and work rather well - if I did not load the xml into an xml table, the processing took about 10 minutes, while the indexed xml table took just a few seconds). statute_xml is the table name and sxmldoc is the xml column/field.
    create index desc_idx on statute_xml
    (sxmldoc.existsNode('/SimpleTypeCompanion/EnumerationValue/@description'))
    create index sid_idx on statute_xml
    (sxmldoc.existsNode
    ('/SimpleTypeCompanion/EnumerationValue/Text')
    create index effdate_idx on statute_xml
    (sxmldoc.existsNode
    ('/SimpleTypeCompanion/EnumerationValue/@effectiveDate')
    Hope this helps.
    Ben

  • Criteria for choosing to create index on column?

    Hello,
    This maybe is a trivial question. I have been reading on performance tuning of SQL queries. What criteria is used to determine which column needs to have an index?
    If a query is as follows:
    Select * from table where column1=<value> and column2=<value> and column3=<value>;What is the criteria for choosing a particular column to be indexed?. Is it the column containing the higher number of unique rows so that index selectivity is high?
    Thanks

    For that particular query, an index on all three columns would be best. However, that's probably not the only query on that table, and you have to take them into account as well.
    What's the main use of your table? What functionality is used most or is most important? Design your index scheme to assist those queries if possible.
    If you have a book, would you use the index? If it's a technical reference book, or an encyclopedia, yes. If it's a novel you read from start to finish, probably not. And if you are reading the Oracle Concepts Manual and you want to search for the paragraphs containing the word "database", would you use an index? And if you search for the logwriter process (LGWR)? It's just about common sense in general: you'll want an index to be selective.
    Another side of the story is that indexes slow down inserts, deletes and updates, so you'll have to make a trade-off: is this penalty worth the speedup of a few queries?
    Regards,
    Rob.

  • H2 devide implicit and explicit created indexes by dictionary views?

    For migrating amounts of data it is useful to drop and recreate indexes and referencing constaints. A implicit created index by defining a primary/unique key constraint will be dropped implicitly by dropping the before mentioned constraint. Creating such a constraint after creating an equivalent index with the constraint name will result in an other behaviour. The explicit created index will not be dropped by dropping the referencing primary/unique key constraint.
    So far so good and well known. The question is: Which dictionary view columns will show me the difference between implicit and explict created indexes if I try to dynamically drop and recreate indexes and unique / primary key constraints?

    Oracle Version is always helpful in answering questions, but for 9i you can find the system generated by:
    dba_indexes.generated = 'Y'
    or
    'SYS_' naming convention for system generated indexes
    or
    dba_constraints.constraint_name = dba_constraints.index_name
    Hope this helps - JTommaney

  • I want information in practical sceario  how to create indexes?

    hi,
    i want complete information about indexes? how create indexes in real time?

    " Secondary Database
    First it must be stated that table design is a more logical work while index design is rather technical. In table design it might make sense to place certain fields (client, company code, ...) in the beginning. In index design, this is not advisable.  Very important for an index is that it contains very selective fields in the beginning. Those are fields like object numbers. Not selective are client, company code, ... 
    Indexes should be small (few fields).  The Database optimizer can combine two or more indexes to execute a query. 
    Indexes of one table should be disjoint (have few common fields), in order not to confuse the optimizer which index to use. 
    Note that each index slows the inserts into the table down. Updates are only slowed down if indexed fields are updated. In general, heavy inserted tables should have only few indexes while heavy selected tables might have more. 
    " Creating Secondary Indexes
    Procedure
    1.In the maintenance screen of the table, choose Indexes.
    If indexes already exist on the table, a list of these indexes is displayed. Choose .
    2.In the next dialog box, enter the index ID and choose 
    The maintenance screen for indexes appears.
    3.Enter an explanatory text in the field Short text.
    You can then use the short text to find the index at a later time, for example with the R/3 Repository Information System.
    4.Select the table fields to be included in the index using the input help for the Field name column.
    The order of the fields in the index is very important. See What to Keep in Mind for Secondary Indexes.
    5.If the values in the index fields already uniquely identify each record of the table, select Unique index.
    A unique index is always created in the database at activation because it also has a functional meaning (prevents double entries of the index fields).
    6.If it is not a unique index, leave Non-unique index selected.
    In this case you can use the radio buttons to define whether the index should be created for all database systems, for selected database systems or not at all in the database.
    7.Select for selected database systems if the index should only be created for selected database systems.
    Click on the arrow behind the radio buttons. A dialog box appears in which you can define up to 4 database systems with the input help. Select Selection list if the index should only be created on the given database systems. Select Exclusion list if the index should not be created on the given database systems. Choose .
    8.Choose  activate.
    " Result
    The secondary index is automatically created in the database during activation if the corresponding table was already created there and index creation was not excluded for the database system.
    You can find information about the activation flow in the activation log, which you can call with Utilities ® Activation log. If errors occurred when activating the index, the activation log is automatically displayed.
    " How to Check if an Index is Used
    Procedure
    1.Open a second session and choose System -> Utilities ->Performance trace.
    The Trace Requests screen appears.
    2.Select Trace on.
    The SQL trace is activated for your user, that is all the database operations under your user are recorded.
    3.In the first window, perform the action in which the index should be used.
    If your database system uses a cost-based optimizer, you should perform this action with as representative data as possible. A cost-based optimizer tries to determine the best index based on the statistics.
    4.In the second session, choose Trace off and then Trace list.
    Result
    The format of the generated output depends on the database system used. You can determine the index that the database used for your action with the EXPLAIN function for the critical statements (PREPARE, OPEN, REPOPEN).
    " What to Keep in Mind for Secondary Indexes
    How well an existing index supports data selection from a table largely depends on whether the data selected with the index represents the data that will ultimately be selected. This can best be shown using an example.
    ' Example  :
    An index is defined on fields FIELD1, FIELD2, FIELD3 and FIELD4 of table BSPTAB in this order. This table is accessed with the SELECT statement:
    SELECT * FROM BSPTAB WHERE FIELD1 = X1 AND FIELD2 = X2 AND FIELD4= X4.
    Since FIELD3 is not specified more exactly, only the index sorting up to FIELD2 is of any use. If the database system accesses the data using this index, it will quickly find all the records for which FIELD1 = X1 and FIELD2 = X2. You then have to select all the records for which FIELD4 = X4 from this set.
    The order of the fields in the index is very important for the accessing speed. The first fields should be those which have constant values for a large number of selections. During selection, an index is only of use up to the first unspecified field.
    Only those fields that significantly restrict the set of results in a selection make sense for an index.
    Reward  points if it is usefull.....
    Girish

Maybe you are looking for