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
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.
MartinFunction 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 -
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 -
Function-based index with OR in the wher-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 I_FUNCTION_TPERSON_NAME and we have a full table scan in the execution-plan.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like a 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 select-statement is:
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
thank you for time..
email: [email protected]In the realistic statement you write :
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
as far as i know, NULL values are not indexed, "or (NAME is NULL)" have to generate a full table scan.
HTH
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 I_FUNCTION_TPERSON_NAME and we have a full table scan in the execution-plan.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like a 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 select-statement is:
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
thank you for time..
email: [email protected] -
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 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 problemTry
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 index getting disabled frequently
I am facing some error like “ORA-30554: function-based index ORADB1.FUN_INDX1 is disabled” in the development database. I verified that the function which is referred by the index is valid. Once I even got the tedious generic error ORA-600 because of this. I referred the metalink and advised to drop and recreate the index
Dropping and recreating the index will solve the issue for 2-3 days and again the same will be repeated. So what I did is made the index unusable as it will not affect the other application activities. Can anybody give a clue on this issue?I am facing some error like “ORA-30554:
function-based index ORADB1.FUN_INDX1 is disabled” Cause: An attempt was made to access a function-based index that has been marked disabled because the function on which the index depends has been changed.
Action: Perform one of the following actions: -- drop the specified index using the DROP INDEX command -- rebuild the specified index using the ALTER INDEX REBUILD command -- enable the specified index using the ALTER INDEX ENABLE command -- make the specified index usable using the ALTER INDEX UNUSABLE command -
Segment Shrinking script erroring out due to Function based indexes, lobs,.
DB version:10gR2
Following is a script i made for freeing up(SHRINK ing and resetting HWM) the space in Tables and its indexes. Due to the existence of LOB Segments and Tables with Function based indexes, this script was erroring out. So i was wondering if there is a way to find out the segments which are eligible/not eligible for Shrinking so that i could make necessary changes to the below script.
create or replace procedure freeup_space
is
type v_segment_type is table of varchar2(30) index by binary_integer;
v_segment v_segment_type;
begin
select segment_name bulk collect into v_segment
from user_segments
where segment_type in ('TABLE')
and segment_name not like 'BIN%';
for i in v_segment.first..v_segment.last loop
execute immediate 'alter table ' || v_segment(i) ||' enable row movement';
dbms_output.put_line('Table '||v_segment(i)||'''s row movement enabled');
execute immediate 'alter table ' || v_segment(i) ||' shrink space cascade';
execute immediate 'alter table ' || v_segment(i) ||' deallocate unused';
end loop;
end;
/You can use USER_LOBS views to look for LOB columns in the segments and ALL_INDEXES.INDEX_TYPE tells if the index is function based index or not.
Message was edited by:
Pierre Forstmann -
Question on Function-based Indexes
hi
I have created one function based index on EMP table as follows
SQL> CREATE INDEX UPP_ENAME ON EMP UPPER(ENAME);
Index created.
as well enable two parameters and analyze the table
SQL> ALTER SESSION SET QUERY_REWRITE_ENABLED =TRUE;
Session altered.
SQL> ALTER SESSION SET QUERY_REWRITE_INTEGRITY =TRUSTED;
Session altered.
SQL> EXECUTE DBMS_STATS.GATHER_TABLE_STATS ('MYTEST','EMP');
PL/SQL procedure successfully completed.
and when I run the following query system is still not using this index.
SQL> SELECT ENAME,EMPNO,JOB FROM EMP WHERE UPPER(ENAME) LIKE 'JAMES';
ENAME EMPNO JOB
JAMES 7900 CLERK
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=18)
1 0 TABLE ACCESS (FULL) OF 'EMP' (Cost=2 Card=1 Bytes=18)
Can anyone explain me why it is not being used.
ThanksSQL> select count(*) "Rows" from acledger;
Rows
1444280
SQL> set timing on
SQL> select * from acledger where nserial like '1';
NSERIAL DTRNDATE DDATEIN CACTCODE NTRNAMT NNARRATION NDOCUMENT
NSOURCE NBRANCH NCURRENCY NEXCHANGE NFCYAMT
1 24-OCT-96 24-OCT-96 650A10001 126876.5 1 200
0 1 6 1 126876.5
Elapsed: 00:00:14.85
SQL> select * from acledger where nserial = '1';
NSERIAL DTRNDATE DDATEIN CACTCODE NTRNAMT NNARRATION NDOCUMENT
NSOURCE NBRANCH NCURRENCY NEXCHANGE NFCYAMT
1 24-OCT-96 24-OCT-96 650A10001 126876.5 1 200
0 1 6 1 126876.5
Elapsed: 00:00:00.29
SQL>
Always "=" faster than "like" operator.
Listen to all other members.
Message was edited by:
user526020
Message was edited by:
user526020 -
Creating function-based indexes
I'm trying to create a function-based index in one of the user's schemas and am getting an insufficient privilege error. Below are the examples:
connect scott/tiger ;
CREATE INDEX emp_ename_idx ON ename( emp ) ;
Index created.
CREATE INDEX upper_ename_idx ON ename( upper(ename)) ;
ERROR at line1:
ORA-01031: insufficient privileges
The DBA granted the CREATE ANY INDEX privilege to user scott already. Any ideas???
Thanks,
SYHi, all.
I didn't hear about function-based index before, so I did some testing. Instead of using Oracle predefined functions (upper, lower, substr etc.), I created my own function and tried to create an index on it. I received an error that function is not deterministic. The definition of deterministic from Oracle docs:
DETERMINISTIC
This hint helps the optimizer avoid redundant function calls. If a stored function was called previously with the same arguments, the optimizer can elect to use the previous result. The function result should not depend on the state of session variables or schema objects. Otherwise, results might vary across calls. Only DETERMINISTIC functions can be called from a function-based index or a materialized view that has query-rewrite enabled.
So, I put word deterministic in function declaration and everything works OK. Then I modified function to use some of the tables (I used tables across different schemas), recreated the index and it also worked fine.
Question - is this statement correct: You can use schema objects in function which is in turn used for indexes as long as you put word deterministic in function declaration and all objects (function, index) will be valid, but ORACLE doesn't guarantee that result produced using that index will be correct?
Thank you. -
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?
ChinniOne 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.KishoreOne 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 -
How can I enable function-based indexes on a already created
database. Is an Installation/Db Creation setting?
On another database I am able to create function-based indexes.
Any help appreciated.
Ashish
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rashmi Rungta ([email protected]):
Hi,
I have a table with huge amount of data and hence I have created
a function-based (Upper) index on one of the character NOT
NULL field which is very likely to be used for query purposes.
First of all though I can create ordinary normal field based
indexes in my user I cannot create a function-based index, why
That had to be created thru SYS user. Secondly I my query
invloving this function is not using the index and instead doing
a full-table scan. Problem outlined below :
Table : PLZPOST, USER / OWNER : PARTNER, FIELD : ORT
INDEX created on UPPER(ORT) in SYS user -
Create index upper_plz_ort on partner.plzpost (upper(ort))
When I give any of the following queries instead of using the
resp. index as mentioned in Oracle DOC it just does a full table
scan (checked thru Explain Plan) :
select * from PLZPOST where upper(ort) is not null;
select * from PLZPOST where upper(ort) like upper('saar%')
select * from PLZPOST where upper(ort) = 'SAARBRUECKEN'
etc etc
If anyone has used Function-based indexes in Oracle 8i could you
please tell me where am I going wrong. Is it because my Table
belongs to PARTNER and Index to SYS (tried running the above
queries under SYS user also but still did not work) ?? If so how
can I grant access on an Index to PARTNER from SYS ??
Your help would be greatly appreciated.
Thanks in advance,
Cheers
Rashmi<HR></BLOCKQUOTE>
null -
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,
TamasOK, problem sorted.
You need to create a check constraint with the same name as the new index, but don't enable it. -
Fail to create a function-based index
Hello,
I'm trying to create a function-based index using the following syntax :
CREATE INDEX fb_name_idx on employees (UPPER(name));
And i've got an ORA-00439 error (function not enabled).
I'm running on Oracle 9.2 Standard edition.
Is this functionality really disabled on standard edition ?
Thanks in advance for your answer,
Guillaume BasilicoNo.
According to this document http://otn.oracle.com/products/database/oracle10g/pdf/twp_general_10gdb_product_family_0104.pdf in the 3rd row on page 12 you can see that Function-Based Indexes are available on Standard Edition.
According to metalink note 69492.1 FBI are available on standard edition.
As for me, I'm too using Oracle 9.2 SE and in my version they are available.
SQL> CREATE INDEX fb_name_idx on tt(trunc(dt));
Index created
SQL> select * from v$version;
BANNER
----------------------------------------------------------Oracle9i Release 9.2.0.4.0 - Production
PL/SQL Release 9.2.0.4.0 - Production
CORE 9.2.0.3.0 Production
TNS for Linux: Version 9.2.0.4.0 - Production
NLSRTL Version 9.2.0.4.0 - Production
Please check exect version number of database and contact your DBA.
Maybe you are looking for
-
Separate gl account for cost center for movement type 201
HI Guys, I have a the following problem: There are three main functional areas i.g Production - (Cost Center 10001) Sales - (Cost Center 10002) Admin - (Cost Center 10003) In obyc we use 5 types of valuation classes like three sets different for prod
-
How can I copy my FF e-mail address book to newly installed T-Bird?
Win7, 32bit, PC. I'm moving to a new ISP (i.e. from BT to Plusnet). I've been using Firefox as both browser and e-mail client but to help me maintain clarity I want to use T-Bird as e-mail client. I would like to copy my address book from Firefox to
-
Help on converting xml file to text file
Hi, I have xml file and i want to convert to text file ... How do i write a perticular tag in perticular line by the time converting xml to text file using xsl ... Ex: input XML file: <NAME> venkat </NAME> <ADDRESS> 5800 Lander Brook Drive </ADDRESS>
-
URL that open Self Service Submit Request page with parameters
Hello, I have a concurrent program on Oracle APPS that generate an output in HTML. I want to have a link in the data that, when click, it takes the information for this line (account_number, header_id etc) and open the web page for submitting request
-
Can`t choose 10.4 as start up system
Hi, I installed System 10.4 on a disk with two partitions. One with 10.2.8 and the other with 10.4. If I open System Preferences and choose the partition with 10.4, and then click on restart, the computer always starts using 10.2.8. It is a G4 sawtoo