Storage for Foreign Keys and Function based indexes

This may well be the silliest question of the day, but is it possible to specify the storage for a Foreign key or a function based index? I'm not even sure that it would make sense.

Well, a foreign key constraint is not a segment, nor is any other type of constraint. However, a function-based index is a segment, just like any other index. So, in that case, specify a tablespace, just like you would with any other index.
Something like this:
create index my_fbi on my_tab(upper(last_name)) tablespace my_index_tablespace;
-Mark
Message was edited by:
mbobak
Fixed minor typo.

Similar Messages

  • Intermedia and function-based indexes

    Is it valid to use function-based indexing to create an intermedia index type ?

    I am interested in this, what's your motivation for function-based index in interMedia text? What kind of function are you going to design?
    Honglin

  • ORA-04091 (table string.string is mutating) and Function-Based Index

    I've encountered a problem with DELETEing from a table when that table has a function-based index on it. The following demonstrates this:
    SQL> CREATE OR REPLACE FUNCTION get_employee_location(p_empno IN number)
      2  RETURN varchar2
      3  DETERMINISTIC
      4  IS
      5  l_return_value   varchar2(20);
      6  BEGIN
      7  SELECT loc
      8  INTO   l_return_value
      9  FROM   dept
    10  WHERE  deptno = (SELECT
    11                   e.deptno
    12                   FROM emp e
    13                   WHERE empno = p_empno);
    14  return l_return_value;
    15  end;
    16  /
    Function created.
    SQL> create index location_idx on emp (get_employee_location(empno));
    Index created.
    SQL> delete from emp;
    delete from emp
    ERROR at line 1:
    ORA-04091: table SCOTT.EMP is mutating, trigger/function may not see it
    ORA-06512: at "SCOTT.GET_EMPLOYEE_LOCATION", line 7------------------------------------------------
    The question is: How can I successfully DELETE FROM emp but keep my function-based index in place?
    Thanks
    Andy

    'Being able to' is 'being able to', but
    it is dangerous to declare "DETERMINISTIC" for non-deterministic function.
    The following problem happens on non-deterministic function index.
    SQL> update dept set loc = 'NEWYORK' where deptno=10;
    1 row updated.
    SQL> commit;
    Commit complete.
    SQL> select * from emp where get_employee_location(deptno)='NEWYORK';
    no rows selected
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEWYORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> select empno,ename from emp where get_employee_location(deptno)='NEW YORK';
         EMPNO ENAME
          7782 CLARK
          7839 KING
          7934 MILLER
    SQL> select empno,ename,get_employee_location(deptno) from emp where deptno=10;
         EMPNO ENAME      GET_EMPLOYEE_LOCATION(DEPTNO)
          7782 CLARK
          7839 KING
          7934 MILLER
    SQL> select empno,ename,get_employee_location(deptno) from emp where get_employee_location(deptno)='NEW YORK';
         EMPNO ENAME      GET_EMPLOYEE_LOCATION(DEPTNO)
          7782 CLARK      NEW YORK
          7839 KING       NEW YORK
          7934 MILLER     NEW YORK
    SQL> drop index location_idx ;
    Index dropped.
    SQL> select empno,ename from emp where get_employee_location(deptno)='NEW YORK';
    no rows selected

  • Is Function-based Index useless ?

    I have a table with 1+ mln records, which has lastupdate (date) column.
    In order to improve performance for it, I created Function-based index on Trunc(lastupdate) column:
    CREATE INDEX idx_trunc_lastupdate
    ON ms_test(TRUNC(LASTUPDATE))
    When I run Explain Plan for my query
    SELECT * FROM ms_test
    WHERE trunc(lastupdate)=trunc(sysdate)
    it chooses Full table scan instead of index.
    Even when I include hint like this
    SELECT /*+ index(MS_TEST, idx_trunc_lastupdate) */
    * FROM ms_test
    WHERE trunc(lastupdate)=trunc(sysdate)
    Explain Plan still chooses full table scan.
    What is wrong here, or maybe hints don't work with function-based indexes ?
    Thanks

    Todd,
    You're right. I can't remember when or where I read that, but I think I tested it and it was true at the time. I just tested it using 8.1.7 and, as you said, it is no longer necessary to match case and whitespace. I included my tests below.
    Barbara
    SQL> CREATE TABLE test_table AS SELECT created FROM user_objects
      2  /
    Table created.
    SQL> CREATE INDEX t_fbi ON test_table (TRUNC (created))
      2  /
    Index created.
    SQL> ANALYZE TABLE test_table
      2  COMPUTE STATISTICS
      3  FOR TABLE
      4  FOR ALL INDEXES
      5  FOR ALL INDEXED COLUMNS
      6  /
    Table analyzed.
    SQL> ALTER SESSION SET QUERY_REWRITE_ENABLED=TRUE
      2  /
    Session altered.
    SQL> ALTER SESSION SET QUERY_REWRITE_INTEGRITY=TRUSTED
      2  /
    Session altered.
    SQL> SET AUTOTRACE ON EXPLAIN
    SQL> SELECT COUNT (*) FROM test_table WHERE TRUNC (created) = TRUNC (SYSDATE)
      2  /
      COUNT(*)                                                                     
             3                                                                     
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=9)            
       1    0   SORT (AGGREGATE)                                                   
       2    1     INDEX (RANGE SCAN) OF 'T_FBI' (NON-UNIQUE) (Cost=1 Card=         
              10 Bytes=90)                                                         
    SQL> SELECT COUNT (*) FROM test_table WHERE trunc(created) = TRUNC (SYSDATE)
      2  /
      COUNT(*)                                                                     
             3                                                                     
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=9)            
       1    0   SORT (AGGREGATE)                                                   
       2    1     INDEX (RANGE SCAN) OF 'T_FBI' (NON-UNIQUE) (Cost=1 Card=         
              10 Bytes=90)                                                

  • Function-Based Indexes for 8.1.6 SE and 9iAS

    I have installed the 9iAS Portal into a 8.1.6 SE database, and I cannot get the Function-Based Index feature to turn on. I have set QUERY_REWRITE_INTEGRITY=trusted, QUERY_REWRITE_ENABLED=true and COMPATIBLE="8.1.0.0.0". The feature will still not enable.
    I have 2 questions:
    1. Is there anything else I can do to turn this feature on.
    2. If not, do I have to upgrade to 8.1.7 or to 8.1.* Enterprise Edition to make use of this feature.

    Could you give the statement for the index you have used, the query you try to do and a description of columns and datatypes of the table? How do you know/check that is doesn't work? Execution plan, errors?...

  • 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 Index and an OR-condition in the WHERE-clause

    We have some problems with functin-based indexes and
    the or-condition in a where-clause.
    (We use oracle 8i (8.1.7))
    create table TPERSON(ID number(10),NAME varchar2(20),...);
    create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
    create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
    The following two statements run very fast on a large table
    and the execution-plan asure the usage of the indexes
    (-while the session is appropriate configured and the table is analyzed):
    1)     select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
    2)     select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
    In particular we see that a normal index is used while the where-clause contains
    an OR-CONDITION.
    But if we try the similarly select-statement
    3)     select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
    the CBO will not use the function-index.
    (This behavior we only expect with views but not with indexes.)
    We ask for an advice like an hint, which enable the CBO-usage
    of function-based indexes in connection with OR.
    This problem seems to be artificial because it contains this dummy logic:
         or (3=5).
    This steams from an prepared statement, where this kind of boolean
    flag reduce the amount of different select-statements needed for
    covering the hole business-logic, while using bind-variables for the
    concrete query-parameters.
    A more realistic (still boild down) version of our prepared select-statement run in
    SQL Plus:
    define x_name = 'MIL%';
    define x_firstname = '';
    select * FROM TPERSON
    where (upper(NAME) like '&x_name' or ( '&x_name' = ''))
    and (upper(FIRSTNAME) like '&x_firstname' or ('&x_firstname' = ''))
    and ...;
    In particular we dont refernce the tablecolumn , but the QUERY-Parameter
    yield the second boolean value in the or-condition.
    The problem is that this condition ('&x_name' = '') dont use any index.
    thanks a lot for spending your time with this problem

    Try
    SELECT /*+ RULE */
    as your hint. I don't have the book with me, but this last weekend I read a section about your very problem. The book was a Oracle Press gold cover about Oracle 8i Performance tuning. If you e-mail me I can quote you the chapter when I get home Friday.

  • Function Based Indexes in Primary Key Definition

    Hello.
    I have been looking into function based indexes. I have been able to create them using unique indexes. However, when I try to create them on primary keys, the engine complains.
    Any ideas? Does anyone know if you can create function based indexes on primary keys?
    An example would be great!
    Thanks,
    Brad

    Hi,
    You can create a function-based Index by going to the Properties dialog for the Index in the Relational model (not the Physical model). If you select the Index Expression tick box, you can then enter the expression into the Expression text area.
    David

  • Syntax for existing function-based index

    Hi:
    I am on 10.2.0.3.
    Listed below is the list of indexes and index columns on one of the tables. Aparantly one of the columns (SYS_NC00220$ ) is in reality a function-based index.
    Anybody knows how to get SQL syntax for this index? TIA.
    INDEX_NAME UNIQUENES COLUMN_NAME COLUMN_POSITION
    PS0BI_HDR NONUNIQUE BILL_TO_CUST_ID 1
    PS0BI_HDR NONUNIQUE BUSINESS_UNIT 2
    PS0BI_HDR NONUNIQUE SYS_NC00220$ 3
    PS1BI_HDR NONUNIQUE BILL_STATUS 1
    PS1BI_HDR NONUNIQUE BUSINESS_UNIT 2
    PS1BI_HDR NONUNIQUE SYS_NC00220$ 3
    PS2BI_HDR NONUNIQUE CONTRACT_NUM 1
    PS2BI_HDR NONUNIQUE BUSINESS_UNIT 2
    PS2BI_HDR NONUNIQUE SYS_NC00220$ 3
    PSABI_HDR NONUNIQUE INVOICE 1
    PSABI_HDR NONUNIQUE BILL_TO_CUST_ID 2
    PSABI_HDR NONUNIQUE BUSINESS_UNIT 3
    PSABI_HDR NONUNIQUE BILL_STATUS 4
    PSBBI_HDR UNIQUE PROCESS_INSTANCE 1
    PSBBI_HDR UNIQUE BUSINESS_UNIT 2
    PSBBI_HDR UNIQUE INVOICE 3
    PS_BI_HDR UNIQUE BUSINESS_UNIT 1
    PS_BI_HDR UNIQUE SYS_NC00220$ 2

    query user_ind_expressions and look for COLUMN_EXPRESSION.
    this will give you expression.

  • Function Based Index And Selectivity

    Hi All,
    I have some doubts w.r.t FBI.I am on 10gR2 (10.2.0.4) with Solaris 5.9
    I was under impression that FBI does not provide guaranteed index access and CBO choose access pattern purely on basis of available stats and query selectivity.
    However, many a times i found that CBO is going for FBI even in case when FTS provides better query elapsed time.
    I created following test case:
    create table fbi_test (id number,flag varchar2(1));
    begin
    for i in 1..1000000
    loop
    insert into fbi_test values(i,'Y');
    end loop;
    end;
    commit;
    begin
    for i in 1..10
    loop
    insert into fbi_test values(i,'N');
    end loop;
    end;
    commit;
    ANALYZE TABLE FBI_TEST COMPUTE STATISTICS;
    CREATE INDEX fbi_test_FBI
    ON fbi_test (CASE WHEN flag = 'Y' THEN 1 ELSE NULL END);
    Autotrace for FBI ACCESS
    SQL> select *from fbi_test where (CASE WHEN flag = 'Y' THEN 1 ELSE NULL END)=1;
    1000000 rows selected.
    Elapsed: 00:00:18.43
    Execution Plan
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 10000 | 50000 | 342 (1)|
    | 1 | TABLE ACCESS BY INDEX ROWID| FBI_TEST | 10000 | 50000 | 342 (1)|
    |* 2 | INDEX RANGE SCAN | FBI_TEST_FBI | 4000 | | 1958 (1)|
    Statistics
    0 recursive calls
    0 db block gets
    136812 consistent gets
    0 physical reads
    0 redo size
    22180292 bytes sent via SQL*Net to client
    733814 bytes received via SQL*Net from client
    66668 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1000000 rows processed
    Autotrace for FTS
    SQL> select *from fbi_test where flag = 'Y';
    1000000 rows selected.
    Elapsed: 00:00:16.56
    Execution Plan
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 500K| 2441K| 371 (9)|
    |* 1 | TABLE ACCESS FULL| FBI_TEST | 500K| 2441K| 371 (9)|
    Statistics
    0 recursive calls
    0 db block gets
    68372 consistent gets
    0 physical reads
    0 redo size
    22180292 bytes sent via SQL*Net to client
    733814 bytes received via SQL*Net from client
    66668 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1000000 rows processed
    FYI...
    SQL> show parameter opt
    NAME TYPE VALUE
    filesystemio_options string asynch
    object_cache_optimal_size integer 102400
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 10.2.0.3
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    plsql_optimize_level integer 2
    My questions are,
    1.why oracle optimizer is going for FBI with high cardinality of 100000 rows?
    2.Why cost of FTS is high (371) as compare to FBI (342) eventhough FTS is having fewer IO (68372) + Less Elapsed Time?
    3.Why Optimizer is considering ELAPSED TIME during plan generation?
    Any inpute would be highly appreciated.

    user635930 wrote:
    Hi All,
    I have some doubts w.r.t FBI.I am on 10gR2 (10.2.0.4) with Solaris 5.9
    Execution Plan
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 10000 | 50000 | 342 (1)|
    | 1 | TABLE ACCESS BY INDEX ROWID| FBI_TEST | 10000 | 50000 | 342 (1)|
    |* 2 | INDEX RANGE SCAN | FBI_TEST_FBI | 4000 | | 1958 (1)|
    ---------------------------------------------------------------------------------You're seeing three different effects here.
    First - for the table access by index, Oracle has "lost" the cost of the index range scan - notice that the total cost of the query is 342, but the cost of the index access is 1958. The total cost of the query should be 2,300 and Oracle should have chosen the full tablescan automatically.
    Second, the stats on the index show just one distinct value for "distinct_keys", and the optimizer has decided (for no reason I can think of - it may be a bug) to assume a 0.4% selectivity on the index.
    Third, the estimated cardinality of the table and index lines differs. Whatever Oracle has done in the index line has been forgotten, and the cardinality of the table line has been based on the predicate given by your case statement and, as a "complex function", that predicate has been given a selectivity of 1% - hence the 10,000 rows estimate.
    The combination of unsuitable statistics, an extreme case, and a couple of quirks in the optimizer mean that the chosen path is clearly unsuitable.
    [Addendum]: It just occurred to me that part of the problem is that you collected stats on the table before you created the index. Given you're running 10g, the 'create index' would automatically generate index stats at the same time - but since it's a function-based index, there's a "virtual column" created for the table as well, and that column won't have any statistics on it - which is why you get the "fixed percentage" selectivities.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "Science is more than a body of knowledge; it is a way of thinking" Carl Sagan
    Edited by: Jonathan Lewis on Nov 29, 2008 1:15 PM

  • How to create function based index for TO_CHAR

    i need to create a function based index for the function to_char.when i tried ,i got an error,"only pure function can be indexed".what the error really means, help me in creating the index 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')Yours seem like a tuning issue, so why not give us your sql and execution plan and so on.
    maybe there is other ways to tune your sql than creating a function based index?

  • Why Segment shrink is not supported for tables with function-based indexes

    As we all know , Segment shrink is not supported for tables with function-based indexes.
    But i'm very confused .
    Why Segment shrink is not supported for tables with function-based indexes ?? what's its essential?

    Creating a function based index creates a hidden virtual column (you'll see it if you query user_tab_cols) and once you index a virtual column you can no longer shrink the table:orcl> create table t1(c1 number,c2 as (c1 * 2)) segment creation immediate;
    Table created.
    orcl> alter table t1 enable row movement;
    Table altered.
    orcl>
    orcl> alter table t1 shrink space;
    Table altered.
    orcl> create index i2 on t1(c2);
    Index created.
    orcl> alter table t1 shrink space;
    alter table t1 shrink space
    ERROR at line 1:
    ORA-10631: SHRINK clause should not be specified for this object
    orcl>so the issue is not with function based indexes per se, it is a level beneath that. Perhaps because the virtual column has no physical existance, when the row is moved there is no reason for Oracle to realize that an index needs updating? I haven't attempted to reverse engineer this, I would be interested to know if anyone else has.

  • Differences between function based index and normal index

    Hi,
    Please Give me some differences between function based index and normal indexes.
    1. Is there any performance gain in function based index?
    2. Why indexes created in DESC are treated as function based?
    3. Every DESC index is b-tree index?
    Thanks

    check this link. This would give u a basic idea of what a function based index is .
    http://www.oracle-base.com/articles/8i/FunctionBasedIndexes.php
    --Prasad                                                                                                                                                                                                                                                                                                                                       

  • How to define error message for function based index violation?

    Hi,
    I am generating Forms 6i from Designer 6i. I have a function based index to enforce case insensitive name uniqueness. With check constraints I can specify constraint violation error messages that will be displayed in Forms at runtime if needed. How can I do this with function based index constraints?
    Regards,
    Tamas

    OK, problem sorted.
    You need to create a check constraint with the same name as the new index, but don't enable it.

  • Why do we need query rewrite enabled for a function-based index?

    Oracle 9i
    ========
    I have searched a few sites but could not find any content on it. The question is why do we need to implement query rewrite enabled when we are trying out a function-based index?
    Thanks in advance.

    You don't, that's a legacy requirement from the early days of function based indexes in Oracle 8i. Here's a quick example running under 9.2.0.6
    drop table t1;
    create table t1 as
    select
    from
         all_objects
    where
         rownum <= 30000
    create or replace function pl_func(i_vc     varchar2)
    return varchar2
    deterministic
    as
    begin
         return soundex(i_vc);
    end;
    -- set the worst case scenario
    alter session set query_rewrite_enabled = false;
    alter session set query_rewrite_integrity = enforced;
    create index t1_i1 on t1(pl_func(object_name));
    execute dbms_stats.gather_table_stats(user, 't1')
    set autotrace traceonly explain
    select
         object_name
    from t1
    where pl_func(object_name) = 'T513'
    set autotrace offResults (after set feedback off)
    SQL> @temp
    Execution Plan
    Plan hash value: 1429545322
    | Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |       |    27 |   675 |    10   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T1    |    27 |   675 |    10   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | T1_I1 |    27 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TEST_USER"."PL_FUNC"("OBJECT_NAME")='T513')
    SQL> spool offRegards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

Maybe you are looking for

  • Problem with ringer after upgrading to ios 6

    I recently upgraded my iphone 4 to ios 6 and immediately the ringer on the phone will not work. I have tried a hard reboot , a restore and investigated all of the sound settings but still nothing works. The speakers work fine ,playing music etc but t

  • ITunes Podcasts Stopped Updating With Upgrade

    Hi, I posted this once before but I've just read on some other posts that .dll files are the problem with some other issues. Is it possible I have a corrupted .dll file that is not letting podcasts update? I've tried uninstalling, re-installing and e

  • How do i get appletv to automaticly download my podcasts?

    does anyone know if this is possible to do without itunes being on?

  • Play an audio file over HTTP

    Hello everybody, I'm trying to play an audio file over HTTP protocol. The code is the following: public class HTTPClientJMF {      static String url = "http://localhost/audio/Reklam1.wav";      static String urlFile = "file:///C://tmp/audio/Reklam1.w

  • Dynamic text based on page number

    Hi Everyone, I'm trying to place a dynamic text on an hrform. The form is displaying wage types and when there are more than 2 pages, the values on the first page need to be summerized into a variable with the text subtotal in front of it. When we ar