FUNCTION-BASED INDEX ( ORACLE 8I NEW FEATURE )

제품 : ORACLE SERVER
작성날짜 : 2004-08-16
FUNCTION-BASED INDEX ( ORACLE 8I NEW FEATURE )
==============================================
SCOPE
10g Standard Edition(10.1.0) 이상 부터 Function-based Index 기능이 지원된다.
Explanation
1. 개요
     Function-based index는, 함수(function)이나 수식(expression)으로 계산
된 결과에 대해 인덱스를 생성하여 사용할 수 있는 기능을 제공한다.
     질의 수행 시 해당 함수나     수식을 처리하여     결과를 가져 오는 것이 아니라,
     인덱스 형태로 존재하는 미리 계산되어 있는 결과를 가지고 처리하므로
     성능 향상을 기할 수 있다.
2. 제약사항
1) aggregate function 에 대한 function-based index 생성 불가.
(예 : sum(...) )
2) LOB, REF, nested table 컬럼에 대한 function-based index 생성 불가.
3. 주요 특징
     1) cost-based optimizer에 의해 사용됨.
     2) B*Tree / bitmap index로 생성 가능.
     3) 산술식 (arithmetic expression), PLSQL function, SQL built-in
function 등에 적용 가능.
     4) 함수나 수식으로 처리된 결과에 대한 range scan 가능
     5) NLS SORT 지원
     6) SELECT/DELETE를 할 때마다 함수나 수식의 결과를 계산하는 것이 아니라
     INSERT/UPDATE 시 계산된 값을 인덱스에 저장.
     7) 질의 속도 향상
     8) object column이나 REF column에 대해서는 해당 object에 정의된
     method에 대해 function-based index 생성 가능.
4. 생성 방법
     CREATE [UNIQUE | BITMAP ] INDEX <index_name>
     ON <tablename> (<index-expression-list>)
     <index-expression-list> -> { <column_name> | <column_expression> }
     예) CREATE INDEX EMP_NAME_INDEX ON EMP (UPPER(ENAME));
     CREATE INDEX EMP_SAL_INDEX ON EMP( SAL + COMM, empno);
     * Function-based index를 생성하기 위해서는 QUERY REWRITE 권한이
     부여 되어 있어야만 한다.
     예) GRANT QUERY REWRITE TO SCOTT;
5. Function-Based Index 사용을 위한 사전 작업
     1) Function-based index는 cost based optimizer에서만 사용 가능하므로,
     테이블에 대해 미리 analyze 해 주는 것이 바람직하다.
     그리고 init 파일에서 OPTIMIZER_MODE 를 FIRST_ROWS 나 ALL_ROWS 등으
로 지정하거나 HINT 등을 사용하여 cost based optimizer가 사용되도록
한다.
     2) init 파일에서 COMPATIBLE 파라미터 값을 8.1 이상으로 설정되어 있어야
한다.
     ( 예 : COMPATIBLE = 8.1.6 )
     3) session/instance level 에서 QUERY_REWRITE_ENABLED 값이 TRUE 지정
되어 있어야 한다.
     ( 예 : ALTER SESSION SET QUERY_REWRITE_ENABLED = TRUE; )
6. 예제
     1) init 파라미터에서 다음과 같이 지정
     compatible = 8.1.6 (반드시 8.1이상이어야 한다)
     query_rewrite_enabled = true
     query_rewrite_integrity = trusted
     2) SCOTT 유저에서 function_based_index 생성
     create index idx_emp_lower_ename
     on emp
     ( lower(ename) ) ;
     3) EMP table analyze
     analyze table emp compute statistics ;
     4) PLAN_TABLE 생성
     @ ?/rdbms/admin/utlxplan.sql
     5) Cost based optimizer 선택
     alter session set optimizer_mode = FIRST_ROWS ;
     6) Query 실행
     explain plan set statement_id='qry1' FOR
     select empno, ename
     from emp
     where lower(ename) = 'ford' ;
     7) PLAN 분석
     SELECT LPAD(' ',2*level-2)||operation||' '||options||' '||object_name query_plan
     FROM plan_table
     WHERE statement_id='qry1'
     CONNECT BY prior id = parent_id
     START WITH id = 0 order by id ;
     -> 결과
     QUERY_PLAN
     SELECT STATEMENT
     TABLE ACCESS BY INDEX ROWID EMP
     INDEX RANGE SCAN IDX_EMP_LOWER_ENAME
7. 결론
Function-based index는 적절하게 사용될 경우 성능상의 많은 이점을 가져
온다. Oracle8i Designing and Tuning for Performance에서도 가능한 한
Function-based index를 사용하는 것을 권장하고 있으며, LOWER(), UPPER()
등의 함수를 사용하여 불가피하게 FULL TABLE SCAN을 하는 경우에 대해서도
효과적으로 처리해 줄 수 있는 방안이라 할 수 있다.
Reference Documents
-------------------

Partha:
From the Oracle8i Administrators Guide:
"Table owners should have EXECUTE privileges on the functions used in function-based indexes.
For the creation of a function-based index in your own schema, you must be
granted the CREATE INDEX and QUERY REWRITE system privileges. To create
the index in another schema or on another schemas tables, you must have the
CREATE ANY INDEX and GLOBAL QUERY REWRITE privileges."
Hope this helps.
Peter

Similar Messages

  • Err ORA-00439 feature not enabled: function-based indexes

    How can I enable function based indexes?
    Database Version is 8i Release 8.1.6.0.0.
    I've done the following steps:
    The init-parameter compatible is set to 8.1.0.0.0.
    I've altered the session parameters
    QUERY_REWRITE_INTEGRITY to TRUSTED and
    QUERY_REWRITE_ENABLED to TRUE.
    But it still doesn't work.
    I would appreciate your help.
    Martin

    Function Based Index feature is not available in the Standard Edition of Oracle. This feature is available ONLY in the Enterprise and Personal Editions.
    Use the V$OPTION view to see the list of installed options.
    If the option is installed, you will see for "Function-based indexes":
    PARAMETER VALUE
    Function-based indexes TRUE
    null

  • Feature availability: Function Based Indexes

    I am currently unable to download the techspecs on Oracle's Standard Edition One to determine if function based indexs are available with this particular licensing option. Does anyone know which licensing versions this feature is available within? I suspect it is only available with the Enterprise Edition.
    Thank you for your time.
    Adam

    Never mind, found the answer within the Oracle Database 10g Product Family (PDF), yes Function based indexes are included with all versions of 10g.

  • Query not considering function based index in oracle 11g

    I have a query which used Function Based Index when run in oracle 9i but when I run the same query
    without any changes, it does not consider index. Below is the query:
    SELECT distinct patient_role.domain_key, patient_role.patient_role_key,
    patient_role.emergency_contact_name,
    patient_role.emergency_contact_phone, patient_role.emergency_contact_note,
    patient_role.emergency_contact_relation_id,
    patient_role.financial_class_desc_id, no_known_allergies, patient_role.CREATED_BY,
    patient_role.CREATED_TIMESTAMP,
    patient_role.CREATED_TIMESTAMP_TZ, patient_role.UPDATED_BY, patient_role.UPDATED_TIMESTAMP,
    patient_role.UPDATED_TIMESTAMP_TZ,
    patient_role.discontinued_date
    FROM encounter, patient_role
    WHERE patient_role.patient_role_key = encounter.patient_role_key
    AND UPPER(TRIM(leading :SYS_B_0 from encounter.account_number)) = UPPER(TRIM(leading :SYS_B_1 from
    :SYS_B_2))
    AND patient_role.discontinued_date IS null
    AND encounter.discontinued_date IS null ;
    Index definition:
    CREATE INDEX "user1"."IX_TRIM_ACCOUNT_NUMBER" ON "user1."ENCOUNTER" (UPPER(TRIM(LEADING
    '0' FROM "ACCOUNT_NUMBER")), "PATIENT_ROLE_KEY", "DOMAIN_KEY", "DISCONTINUED_DATE")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
    BUFFER_POOL DEFAULT)
    TABLESPACE "user1"
    Database : Oracle 11g (11.2.0.3)
    O/S : Linux 64 bit (the query does not consider index even on windows os)
    Any suggestions?
    -Onkar
    Edited by: onkar.nath on Jul 2, 2012 3:32 PM

    Onkar,
    I don't appreciate you posting this question in several forums at the same time.
    If I would know you also posted this on Asktom, I wouldn't even have bothered.
    As to your 'issue':
    First of all: somehow cursor_sharing MUST have been set to FORCE. Oracle is a predictable system, not a fruitmachine.
    Your statement the '0' is replaced by a bind variable anyway is simply false. If you really believe it is not false, SUBMIT a SR.
    But your real issue is not Oracle: it is your 'application', which is a mess anyway. Allowing for alphanumeric numbers is a really bad idea.
    Right now you are already putting workaround on workaround on workaround on workaround.
    Issue is the application: it is terminal., and you either need to kill it, or to replace it.
    Sybrand Bakker
    Senior Oracle DBA

  • Oracle 8i Function-based index

    Hi,
    i have problem with making Oracle8i to use function-based index. I am using version 8.1.6 Enterprise Edition.
    So here is the test I did
    CREATE INDEX first_name_index ON customer ( UPPER(first_name)) ;
    alter session set QUERY_REWRITE_ENABLED = TRUE;
    alter session set QUERY_REWRITE_INTEGRITY=TRUSTED;
    ANALYZE TABLE customer COMPUTE STATISTICS;
    alter index first_name_index compute statistics;
    Everything seemed to be as required by Oracle but it doesn't use this function-based index when I make
    select *
    from customer
    where upper(first_name) like 'J%';
    I test it on large table and with table with few hundred rows. I don't have NULLs in that field.
    Can anyone help me with this.

    I would not create an index to have it prepared for an ORDER BY. An index is quite costly in DML opperations and space as well. More, a function based index will be costlier as the function has to be called for every read and/or write.
    Do not forget that indexes a created for a direct access to data and not for sorting purposes.
    George

  • Function-based indexes don't seem to work in Oracle 8.1.5?

    Hi,
    What gives? What am I doing wrong? I have a table AIRPORT with a column (varchar2(64)) which I have specified a function based index for, but I can't get SQL wueries to use it!!!! the following SQL executes a FULL TABLE SCAN:
    select /*+ index (a idx_upper_cityname) */ *
    from airport a
    where nls_upper(cityName) = 'dfdf'
    ...as does...
    select *
    from airport a
    where nls_upper(cityName) = 'dfdf'
    Table and index code is as follows:
    CREATE TABLE airport
    id NUMBER NOT NULL,
    citycode VARCHAR2(3) NOT NULL,
    cityname VARCHAR2(64) NOT NULL,
    state VARCHAR2(2),
    country VARCHAR2(2) NOT NULL,
    region CHAR(1),
    airportcode VARCHAR2(3) NOT NULL,
    airportname VARCHAR2(64),
    code VARCHAR2(4)
    drop index idx_upper_cityname
    CREATE INDEX idx_upper_cityname ON airport nls_upper(substr(cityName, 0, 64) )
    Environment is as follows:
    Oracle8i v8.1.5 running on WinNT v4.0 (SP 5)
    Client is running on the same machine
    thanks in advance,
    Alexander

    New data point: when I set the handler in my logging.properties file thusly,
    org.apache.catalina.core.ContainerBase.[Catalina].[info-dev].[/infoisland].level = ALL
    org.apache.catalina.core.ContainerBase.[Catalina].[info-dev].[/infoisland].handlers = java.util.logging.ConsoleHandlerI get 0 bytes in the info-dev log (which used to have the aforementioned expception in it). Where is my console going?

  • Function based indexes on CLOB storage

    On a 10gR2 database, with schema-less CLOB storage for an XMLType column:
    (1) Can a function based index include a wildcard in the namespace ? Or do I need a new function based index for each specific namespace ?
    (2) I must create a new function based index for each different element that I want an indexed search on ?
    (3) What limit is there on the number of function based indexes per table ?
    (4) I believe XQuery can include a wildcard for namespaces, but XPath 1.x can't. Can I create a function based index using XQuery, rather than XPath ?
    Documents conforming to different versions of an XML schema will be present (schema versioning), but I want to search across all documents irrespective of a specific namespace - e.g. "Find any document with reference = 'some Value' , and amount = 1000".
    CLOB storage is proposed, due to the need to handle documents from multiple versions of an XML schema. The knowledge of the XSD is not known at development time, but is user definable, and it must be possible to change the structure without system down time. Structured storage is not suitable, due to Oracle's requirement for downtime if the schema changes (CopyEvolve drops/recreates tables), and Oracle doesn't support schema collections, so you can't bind an XML column to multiple schemas.
    Here is some sample code of what I'm trying to do:
    create table BulkTest
    ID NUMBER(10) not null primary key,
    USERFIELDS XMLTYPE
    create sequence S_BulkTest;
    --Document conforming to version 1 of schema
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395-1">
         <reference>FH12345678</reference>
         <relatedReference>FH23456789</relatedReference>
         <queries>Here is some query text.</queries>
         <narrative>Here is some narrative text.</narrative>
         <relatedMessageType>300</relatedMessageType>
         <relatedMessageDate>2005-03-29</relatedMessageDate>
         <direction>R</direction>
         <sessionNumber>1234</sessionNumber>
         <isn>123456</isn>
         <relatedMessageDescription>This is the deal where I bought USD 1 million for GBP at 1.76.</relatedMessageDescription>
         <otherParty>232332</otherParty>
    </mt395>'
    --Document conforming to version 2 of schema
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395-2">
         <guid>0f9a08f6-b052-4693-baba-8f7dc881e7e8</guid>
         <reference>333333</reference>
         <queries>Another query</queries>
         <narrative>Some narrative</narrative>
         <direction>R</direction>
         <sessionNumber>1234</sessionNumber>
         <isn>223456</isn>
    </mt395>'
    --It seems I need to create a new index for each field I want to search on
    create index iBulkTest_REFERENCE
    on BulkTest
    (extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-1"'));
    --And that a new index is required for each specifc namespace that is present
    --Can't we include a wildcard in the namespace ?
    create index iBulkTest_REFERENCE_2
    on BulkTest
    (extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"'));
    --If I want to query, I have to explicitly specify each namespace.
    --Can't I specify a wildcard ?
    --This will make it "fun" querying across namespaces!
    select
    id,
    extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"') As Reference,
    t.userfields.getclobval() userfields
    from bulktest t
    WHERE extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"') = '333333'

    Andy
    #1. You do not have scehma versioning here. Your model is totally incorrect. You shoud not change the namespace when versioning the XML Schema. You have 2 different and totally disjoint XML Schemas. The correct was to version, as distinct from evolve an XML Schema is to change the Schema Location Hint associated with your XML...
    Eg
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:incident:mt395 mt395-1.xsd">
    <reference>FH12345678</reference>
    <relatedReference>FH23456789</relatedReference>
    <queries>Here is some query text.</queries>
    <narrative>Here is some narrative text.</narrative>
    <relatedMessageType>300</relatedMessageType>
    <relatedMessageDate>2005-03-29</relatedMessageDate>
    <direction>R</direction>
    <sessionNumber>1234</sessionNumber>
    <isn>123456</isn>
    <relatedMessageDescription>This is the deal where I bought USD 1 million for GBP at 1.76.</relatedMessageDescription>
    <otherParty>232332</otherParty>
    </mt395>'
    --Document conforming to version 2 of schema
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:incident:mt395 mt395-2.xsd">
    <guid>0f9a08f6-b052-4693-baba-8f7dc881e7e8</guid>
    <reference>333333</reference>
    <queries>Another query</queries>
    <narrative>Some narrative</narrative>
    <direction>R</direction>
    <sessionNumber>1234</sessionNumber>
    <isn>223456</isn>
    </mt395>'
    This is the correct way of versioning an XML Schema. THe namespace stays the same, the SchemaLocationHint in the SchemaLocation tag changes.
    Bear in mind that if you use the technique you are currently using you will make any path expressions you need to write absolutely unmaintaining and the processing of them very inefficient.
    Some questions to consider
    Node 'X' in namespace 'X' is never the same as Node 'X' in namespace 'Y'.
    How would you write an Xpath or XQuery that targetted multiple versions, but not all versions ?
    What happens if you have other documents that are really in a different namespace ? Using wildcards can you differentiate them..
    From the problem you are describing and the terminolgy you are using it looks like you've been an early customer of Yukon. MSFT clearly didn't understand schema versioning in the early beta releases and used the 'change the namespace' schema for modelling schema versioning.
    We do have some technology coming down the pipe which can address the issue, regardless of whether or not it is too late for you to correct the versioning scheme you have selected. However I cannot discuss that in a public forum. If you want to learn about these features and are prepared to enter an NDA with Oracle in order to do so please contact me directly. You can do this a number of ways...
    Guess my email address @oracle.com
    Post your email address here and I'll delete the post as soon as I have it..
    Update your OTN Forum profile to include your email address
    Open a TAR and post the tar number here. You can then softclose the tar as this is simply a method for me to get your contact info.

  • Function based indexes on object tables

    Hi,
    I am trying to create a function based index on an object table. I am getting the following error:
    SQL> create index cell1_indx on cell1(create_cell1(id)) indextype is mdsys.spatial_index;
    create index cell1_indx on cell1(create_cell1(id)) indextype is mdsys.spatial_index
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13249: internal error in Spatial index: [mdidxrbd]
    ORA-13249: Error in Spatial index: index build failed
    ORA-13249: Stmt-Execute Failure: SELECT num_rows from all_tables where owner='ASHE' and table_name=
    'CELL1'
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 7
    ORA-06512: at line 1
    Here cell1 is an object table.
    Is the procedure for creating function based indexes on object tables different from relational tables?
    Chinni

    One of the many new features in Oracle 8i is the Function-Based Index (we will refrain from using FBI, but only just). This allows the DBA to create indexes on functions or expressions; these functions can be user generated pl/sql functions, standard SQL functions (non-aggregate only) or even a C callout.
    A classic problem the DBA faces in SQL Tuning is how to tune those queries that use function calls in the where clause, and result in indexes created on these columns not to be used.
    Example
    Standard B-Tree index on SURNAME with cost based optimizer
    create index non_fbi on sale_contacts (surname);
    analyze index non_fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts
    WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 TABLE ACCESS (FULL) OF 'SALES_CONTACTS' (Cost=3 Card=16 Bytes=272)
    Now we use a function based index
    create index fbi on sale_contacts (UPPER(surname));
    analyze index fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (RANGE SCAN) OF 'FBI' (NON-UNIQUE) (Cost=2 Card=381 Bytes=6477)
    The function-based index has forced the optimizer to use index range scans (retuning zero or more rowids) on the surname column rather than doing a full table scan (non-index lookup). Optimal performance does vary depending on table size, uniqueness and selectivity of columns, use of fast full table scans etc. Therefore try both methods to gain optimal performance in your database.
    It is important to remember that the function-based B*Tree index does not store the expression results in the index but uses an "expression tree". The optimizer performs expression matching by parsing the expression used in the SQL statement and comparing the results against the expression-tree values in the function-based index. This comparison IS case sensitive (ignores spaces) and therefore your function-based index expressions should match expressions used in the SQL statement where clauses.
    Init.ora Parameters
    The following parameter must be set in your parameter file: QUERY_REWRITE_INTEGRITY = TRUSTED
    QUERY_REWRITE_ENABLED = TRUE
    COMPATIBLE = 8.1.0.0.0 (or higher)
    Grants
    Grants To create function-based indexes the user must be granted CREATE INDEX and QUERY REWRITE, or alternatively be granted CREATE ANY INDEX and GLOBAL QUERY REWRITE. The index owner must have EXECUTE access on the function used for the index. If execute access is revoked then the function-based index will be "disabled" (see dba_indexes).
    Disabled Indexes
    If your function-based index has a status of "disabled" the DBA can do one of the following:
    a) drop and create the index (take note of its current settings)
    b) alter index enable, function-based indexes only, also use disable keyword as required
    c) alter index unusable.
    Queries on a DISABLED index fail if the optimizer chooses to use the index.Here is an example ORA error:
    ERROR at line 1: ORA-30554: function-based index MYUSER.FBI is disabled.
    All DML operations on a DISABLED index also fail unless the index is also marked UNUSABLE and the initialization parameter SKIP_UNUSABLE_INDEXES is set to true.
    Some more Examples
    CREATE INDEX expression_ndx
    ON mytable ((mycola + mycolc) * mycolb);
    SELECT mycolc FROM mytable
    WHERE (mycola + mycolc) * mycolb <= 256;
    ..or a composite index..
    CREATE INDEX example_ndx
    ON myexample (mycola, UPPER(mycolb), mycolc);
    SELECT mycolc FROM myexample
    WHERE mycola = 55 AND UPPER(mycolb) = 'JONES';
    Restriction & Rule Summary
    The following restrictions apply to function based indexes. You may not index:
    a) LOB columns
    b) REF
    c) Nested table column
    d) Objects types with any of the above data types.
    Function-based indexes must always follow these rules:
    a) Cost Based optimizer only, must generate statistics after the index is created
    b) Can not store NULL values (function can not return NULL under any circumstance)
    c) If a user defined pl/sql routine is used for the function-based index, and is invalidated, the index will become "disabled"
    d) Functions must be deterministic (always return the same value for a known input)
    e) The index owner must have "execute" access on function used in the function-based index. Revocation of the privilege will render the index "disabled"
    f) May have a B-Tree and Bitmap index type only
    g) Can not use expressions that are based on aggregate functions, ie. SUM, AVG etc.
    h) To alter a function-based index as enabled, the function used must be valid, deterministic and the signature of the function matches the signature of the function when it was created.
    Joel P�rez

  • Function based indexes doing full table scan

    Guys,
    I am testing function based indexes and whatever I do
    it is doing a full table scan.
    1)I have set the following init parameters as
    QUERY_REWRITE_ENABLED=TRUE
    QUERY_REWRITE_INTEGRITY=TRUSTED
    2)CREATE INDEX i3 ON emp(UPPER(ename));
    3) ANALYZE TABLE emp COMPUTE STATISTICS
    ANALYZE INDEX I3 COMPUTE STATISTICS
    4) DELETE plan_table;
    5) EXPLAIN PLAN SET statement_id='Test1' FOR
    SELECT ename FROM emp WHERE UPPER(ename) = 'KING';
    6) SELECT LPAD(' ',2*level-2)||operation||' '||options||' '||object_name
    query_plan
    FROM plan_table
    WHERE statement_id='Test1'
    CONNECT BY prior id = parent_id
    START WITH id = 0 order by id
    7) And the query plan shows as
    SELECT STATEMENT
    TABLE ACCESS FULL EMP
    I am using 9.0.1.4 !!!
    Any help is appreciated !!!
    Regards,
    A.Kishore

    One of the many new features in Oracle 8i is the Function-Based Index (we will refrain from using FBI, but only just). This allows the DBA to create indexes on functions or expressions; these functions can be user generated pl/sql functions, standard SQL functions (non-aggregate only) or even a C callout.
    A classic problem the DBA faces in SQL Tuning is how to tune those queries that use function calls in the where clause, and result in indexes created on these columns not to be used.
    Example
    Standard B-Tree index on SURNAME with cost based optimizer
    create index non_fbi on sale_contacts (surname);
    analyze index non_fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts
    WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 TABLE ACCESS (FULL) OF 'SALES_CONTACTS' (Cost=3 Card=16 Bytes=272)
    Now we use a function based index
    create index fbi on sale_contacts (UPPER(surname));
    analyze index fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (RANGE SCAN) OF 'FBI' (NON-UNIQUE) (Cost=2 Card=381 Bytes=6477)
    The function-based index has forced the optimizer to use index range scans (retuning zero or more rowids) on the surname column rather than doing a full table scan (non-index lookup). Optimal performance does vary depending on table size, uniqueness and selectivity of columns, use of fast full table scans etc. Therefore try both methods to gain optimal performance in your database.
    It is important to remember that the function-based B*Tree index does not store the expression results in the index but uses an "expression tree". The optimizer performs expression matching by parsing the expression used in the SQL statement and comparing the results against the expression-tree values in the function-based index. This comparison IS case sensitive (ignores spaces) and therefore your function-based index expressions should match expressions used in the SQL statement where clauses.
    Init.ora Parameters
    The following parameter must be set in your parameter file: QUERY_REWRITE_INTEGRITY = TRUSTED
    QUERY_REWRITE_ENABLED = TRUE
    COMPATIBLE = 8.1.0.0.0 (or higher)
    Grants
    Grants To create function-based indexes the user must be granted CREATE INDEX and QUERY REWRITE, or alternatively be granted CREATE ANY INDEX and GLOBAL QUERY REWRITE. The index owner must have EXECUTE access on the function used for the index. If execute access is revoked then the function-based index will be "disabled" (see dba_indexes).
    Disabled Indexes
    If your function-based index has a status of "disabled" the DBA can do one of the following:
    a) drop and create the index (take note of its current settings)
    b) alter index enable, function-based indexes only, also use disable keyword as required
    c) alter index unusable.
    Queries on a DISABLED index fail if the optimizer chooses to use the index.Here is an example ORA error:
    ERROR at line 1: ORA-30554: function-based index MYUSER.FBI is disabled.
    All DML operations on a DISABLED index also fail unless the index is also marked UNUSABLE and the initialization parameter SKIP_UNUSABLE_INDEXES is set to true.
    Some more Examples
    CREATE INDEX expression_ndx
    ON mytable ((mycola + mycolc) * mycolb);
    SELECT mycolc FROM mytable
    WHERE (mycola + mycolc) * mycolb <= 256;
    ..or a composite index..
    CREATE INDEX example_ndx
    ON myexample (mycola, UPPER(mycolb), mycolc);
    SELECT mycolc FROM myexample
    WHERE mycola = 55 AND UPPER(mycolb) = 'JONES';
    Restriction & Rule Summary
    The following restrictions apply to function based indexes. You may not index:
    a) LOB columns
    b) REF
    c) Nested table column
    d) Objects types with any of the above data types.
    Function-based indexes must always follow these rules:
    a) Cost Based optimizer only, must generate statistics after the index is created
    b) Can not store NULL values (function can not return NULL under any circumstance)
    c) If a user defined pl/sql routine is used for the function-based index, and is invalidated, the index will become "disabled"
    d) Functions must be deterministic (always return the same value for a known input)
    e) The index owner must have "execute" access on function used in the function-based index. Revocation of the privilege will render the index "disabled"
    f) May have a B-Tree and Bitmap index type only
    g) Can not use expressions that are based on aggregate functions, ie. SUM, AVG etc.
    h) To alter a function-based index as enabled, the function used must be valid, deterministic and the signature of the function matches the signature of the function when it was created.
    Joel P�rez

  • Function Based Index

    Hi All,
    select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionI have a 10GB partitioned table which has INVOICE_DUE_DATE column. Table is partitioned on CREATION_DATE. All records which has CREATION_DATE less than 01-jan-2010 have INVOICE_DUE_DATE set to NULL and new records (for year 2011)are updated with recent date(i.e. sysdate) by 'due_date_update' process. Some developers want indexing on INVOICE_DUE_DATE column as they have SLA critical reports running against INVOICE_DUE_DATE column. (where INVOICE_DUE_DATE > :B1) B1 could be any date in 2011.
    As of now, ~85% records are having INVOICE_DUE_DATE set to NULL.
    Given above scenarios,Can i use function based index to index all rows where INVOICE_DUE_DATE is any date in 2011 ?
    Edited by: OraDBA02 on Jan 11, 2011 4:00 AM

    OraDBA02 wrote:
    Given above scenarios,Can i use function based index to index all rows where INVOICE_DUE_DATE is any date in 2011 ?I suppose you could, but you might not need to. If you had an index that just contained the INVOICE_DUE_DATE column it wouldn't index the NULL values anyways.

  • Function-Based Index enabling.

    Hi...
    I'm trying to create a function-based index along the lines of:
    CREATE INDEX x_ssn4
    ON table_y(SUBSTR(ssn,6,4))
    UNRECOVERABLE;
    ...so as to be able to query the final 4 digits of social security numbers. Problem is that the above elicits an ORA-00439 "feature not enabled" message. I'm running 8.1.6 and have tried setting the Oracle parameter QUERY_REWRITE_ENABLED to 'TRUE' via an ALTER SESSION command, but to no avail.
    Anyone know how to 'turn the feature on'?
    Thanks, Rob

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rick Post:
    I've always done it by logging on as SYS and executing a 'grant query rewrite to myuser'.
    <HR></BLOCKQUOTE>
    Thanks... but turns out that the privilege is not really the issue, as the ALTER SESSION command works. I figured out that the problem was the setting for COMPATIBLE. It pointed to 8.0.0 instead of 8.1.x which is what was needed to permit function-based indexing.
    ~Rob
    null

  • Importing error: related to function-based indexes?

    I've come across a strange error. I've got a user that has an export dump file who wants me to import the data into a new database. (Its an Oracle 10G database.)
    When I use the 'imp' command, the table import completes successfully, but I end up receiving the following warnings:
    IMP-00003: oracle error 942 encountered
    ORA-00942: table or view does not exist
    IMP-00017: following statement failed with ORACLE error 942
    "CREATE INDEX "X" on "Y" (TO_CHAR("Z",'yyyymmdd')) P"
    "CTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 3145728 FREELISTS 1 FREEL"
    "IST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TBSPC" LOGGING"
    The table itself seems to have been imported correctly; and all data rows exist. Its just the index that isn't being imported/rebuilt. (Other indexes on the same table were imported properly.)
    The only thing that I could find that seems odd is that this index uses functions (the "TO_CHAR" in the index above). All of the other indexes on the table refer to basic fields. And I can rebuild the index manually.
    Is the 'imp' command able to handle function-based indexes? Is there some parameter than I need to set to allow it to import these indexes?
    (I know the more efficient thing to do would be to do an import with no indexes and rebuild them later...)
    Edited by: user588235 on Dec 9, 2009 5:16 PM

    Function based indexes should be supported. If it is exported, then it should be able to be imported. This just seems like a weird case. Have you tried to create a different table and then create a function based index on that table then see if exp/imp work?Yes, I have tried creating new versions of the tables (both with and without function-based indexes).
    During my tests, I found that I can recreate the problem if I create the table in Oracle 9 and import it into Oracle 10; the problem doesn't occur when importing/exporting between Oracle9->Oracle9 or Oracle10->Oracle10. (However, the user told me that this was an export from Oracle 10.)
    One other thing: I've noticed that if, instead of importing into a user account, I import into the system account, it works with no problems. For example:
    imp userid='sys/xyz as sysdba' file=mydata.dmp fromuser=use1 touser=use2 ->Results in warnings while reading indexes
    imp userid='sys/xyz as sysdba' file=mydata.dmp fromuser=use1 touser=sys ->works with no warning
    This makes me suspect that its a problem with the permissions that have been granted. (I've granted 'create any index' and 'query rewrite' to the user account however.)
    Not to change the issue, but since this is 10g, have you tried using datapump to expdp/impdp the same information?Might be an option; problem is, I'm dealing with a legacy system that was set up to use 'imp/exp', so altering backup and restore methods will require a lot of work.

  • ORA-00439 while creating function based indexes.

    Hi everybody
    I'm working on Oracle 8.1.7 database, and try to create a function based index on a table.
    Unfortunately I get the ORA-00439 error, that recommends me not to use this feature :-(
    What should I do to activate this feature ?
    Thanx

    Try.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bi
    PL/SQL Release 10.1.0.2.0 - Production
    CORE    10.1.0.2.0      Production
    TNS for Solaris: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production

  • Whether Function Based indexes are included in Oracle10 Standard edition?

    Hi
    Could you please tell me whether Function Based indexes are included in Oracle Standard edition 10.2.
    Can you provide me the link to check the features available with 10.2 standard edition.
    Thanks in advance...

    Hi Madrid
    Function Based Indexes is a feature from Enterprise Edition.Interesting... But why do you think so? I mean, if it is the case, the documentation should mention it...
    IMO the reference is the guide about licensing. But if you know that somewhere else such an information is provided, please, give us a link.
    Thank you,
    Chris

  • Performance problem on function-based index

    Hi guys,
    I am having performance problems with the addition of new function-based indexes.
    alter session set nls_comp='ANSI';
    alter session set nls_sort='BINARY_CI';
    * have to run this because the of case-insensitivity requirements
    I have a view. for ex:
    create or replace view view1
    as
    select * from emp1,user
    where emp1.empno=user.empno
    union
    select * from emp2,user
    where emp2.empno=user.empno
    union
    select * from emp3,user
    where emp3.empno=user.empno and so on
    When I run this it works with a full table scan. Then when i created a function-based index:
    create index user_ix on
    user(nlssort(empno,'NLS_SORT=BINARY_CI'));
    analyze index user_ix compute statistics;
    analyze table user compute statistics;
    the view hangs. but when i run the individual select statements it works.
    Do you guys have any idea on what's going on? Any advise is greatly appreciated.
    Thanks.

    LC is absolutely right. Brain cramp on my part.
    On the other hand, I can't seem to coerce Oracle to apply a to_binary_double conversion as part of an implicit conversion.
    var bin_dbl binary_double;
    select to_binary_double(14) into :bin_dbl from dual;
    SCOTT @ nx102 JCAVE9420> select * from emp where empno = :bin_dbl;
    no rows selected
    Elapsed: 00:00:00.14
    Execution Plan
    Plan hash value: 2949544139
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    39 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    39 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=TO_NUMBER(:BIN_DBL))I'd expect that Oracle would try to convert the binary double to a number, not the other way around.
    Justin

Maybe you are looking for

  • Google Voice not working. Is the blame with enabling Advanced Calling?

    Have any Verizon users had more than the usual amount of trouble setting up Google Voice for voicemail? I previously used Google Voice as my voicemail on my Galaxy Note 4, which required the standard workaround to get it working with Verizon (calling

  • Gdm 1080p small font

    Hi fellas, I got arch installed on my media pc hooked up to a 1080p lcd TV (using dvi to hdmi cabling).  The problem i have is that in gdm, the fonts are inscrutably small and unlegible.  They are just tiny...  I'm using 1920x1080 and the text look l

  • Converting Blu-Ray

    I was wondering if anyone knows if it is possible to convert Blu-Ray to MKV in Arch? Would save me spending time in Windows 7 if I can do it in Arch. I can don't mind pre-ripping it to m2ts in Windows but it takes so long it would be nice ti be able

  • IDoc error - Condition type & tax code & does not exist

    Hi, I have the problem with CANADA tax codes. I have a few documents sent from external SAP to different SAP. In the source system documents were posted. In the target system i have error "Condition type & tax code & does not exist". I have compared

  • Grrrrr..... What on earth is going on with the quicktime convert to mp4?

    What on earth is going on with MP4 / quicktime? To convert an avi. file to mp4 is taking as long as it takes to watch the entire movie! I am converting a movie from avi. over to mp4 using the ($44) upgrade facility on quicktime and it is taking the l