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
Similar Messages
-
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.
AdamNever mind, found the answer within the Oracle Database 10g Product Family (PDF), yes Function based indexes are included with all versions of 10g.
-
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 -
Hi Guys,
We are running Oracle 8.1.7 Database on Solaris server. We created function based indexes, while executing queries the function based indexes are not being used. Only if we use a hint in the query the indexes are being used. Is this a bug in oracle 8.1.7 or is this is how the function based indexes have to be used. Can somebody clarify this issue, I will appreciate your help. Thanks in advance.First, have you analyzed the tables recently? I believe you have to be using the CBO if you're using function based indexes. If the CBO has bad statistics, it may be generating bad plans.
Second, can you post the query & the plan (with and without the hint)? Is it possible that the CBO is finding a better plan than using the index?
Justin -
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. -
Auto Stats Collection on function based indexes
In 10g does AUTO Stats Collection job in the default weeknight / weekend window collect stats on "function based indexes".
Thank You
Message was edited by:
user449511
I got the reply in another similar post posted by me some time earlier.
Thank You
Message was edited by:
user449511SELECT job_name, comments
FROM dba_scheduler_jobs;Then refine your search using the columns in the view. -
Function Based Indexes - negative performance
Has anyone run across any cases where they have had issues with Function Based Indexes negatively impacting performance??
We are trying to use function based indexes in 9i (NLS_SORT=GENERIC_BASELETTER) and 10g (NLS_SORT=BINARY_CI) for case insensitivity.
We thought this was a decent solution until recently when testing with larger datasets. Any info is appreciated.
Thanks,Just to clarify rreynoldson's first point:
All indexes will negatively impact inserts. Indexes, including function-based indexes, may or may not improve update and delete performance depending on whether the overhead of maintaining the index outweighs the benefit of being able to use the index to find the row(s) to update relatively quickly.
For user564260:
Assuming those parameters are set, make sure that you've gathered statistics on the function based index. If that doesn't resolve the problem, can you post a small test case that demonstrates the problem where you
- Create the table
- Create the indexes
- Populate it with data
- Run the query that you'd expect to use the FBI
- Post the explain plan
that would help us immensely.
Justin -
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. -
Using function based index causing connection to abort
My problem is as below
I m using oracle 8i data base
I have a table Dummy with column col1 .
I have created a function based index on col1
Now i try to update the table dummy using this function based index (i.e)
i run the following query
update dummy set col2='new value' where col1=ltrim(col2,'0')
now when i execute this statement it causes the connection to abort. It gives the error
ERROR at line 1:
ORA-03113: end-of-file on communication channel
But if i run select query (i.e) select col2 from dummy where col1=ltrim(col2,'0')
it executes sucessfully.
Also if i wrap the ltrim over some other function it works (i.e.)
update dummy set col2='new value' where col1=upper(ltrim(col2,'0'))
Any thoughts or ideas on what can be the reason...
plese let me know for any questions,clarifications..
Thanks in advance...
BalajiBalaji, what is the exact error message returned? Remember to always include all the error details so that the problem can be identified and diagnosed.
If you mean you are getting an ORA-03113: end-of-file on communication channel, this means that the Oracle Server Process that serviced your client session, crashed.
In that case you need to refer to the alert log file on the database instance to see the server-side error message that resulted (often an ORA-0600 internal error) and the name of the trace file that was created at a result.
You also failed to specify the exact Oracle 8i version you are using. Make sure you're on the very last patch set released for 8i - that should be 8.1.7.4 as far as I recall. -
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] -
Creation of function based index using escape
Hello,
I have the following SQL, sometimes performing bad:
SELECT DISTINCT UPPER(A.PROCESSIDCODE), UPPER(A.RULENAME), CHARSET
FROM XIB_DETECT A, XIB_PROCESSIDPROPERTIES B, XIB_RULES C
WHERE ( A.KEY1 = :P1 OR ( :P1 like REPLACE(REPLACE(REPLACE(REPLACE(KEY1,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS1 = 'Y') OR A.KEY1 = '*' AND A.REGFLAGS1 = 'Y')
AND (A.KEY2 = :P2 OR ( :P2 like REPLACE(REPLACE(REPLACE(REPLACE(KEY2,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS2 = 'Y') OR (A.KEY2 IS NULL AND A.REGFLAGS2 IS NULL ) )
AND (A.KEY3 = :P3 OR ( :P3 like REPLACE(REPLACE(REPLACE(REPLACE(KEY3,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS3 = 'Y') OR (A.KEY3 IS NULL AND A.REGFLAGS3 IS NULL ) )
AND (A.KEY4 = :P4 OR ( :P4 like REPLACE(REPLACE(REPLACE(REPLACE(KEY4,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS4 = 'Y') OR (A.KEY4 IS NULL AND A.REGFLAGS4 IS NULL ) )
AND (A.KEY5 = :P5 OR ( :P5 like REPLACE(REPLACE(REPLACE(REPLACE(KEY5,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS5 = 'Y') OR (A.KEY5 IS NULL AND A.REGFLAGS5 IS NULL ) )
AND (A.KEY6 IS NULL OR A.KEY6 = '*' AND REGFLAGS6 = 'Y')
AND (A.KEY7 IS NULL OR A.KEY7 = '*' AND REGFLAGS7 = 'Y')
AND (A.KEY8 IS NULL OR A.KEY8 = '*' AND REGFLAGS8 = 'Y')
AND (A.KEY9 IS NULL OR A.KEY9 = '*' AND REGFLAGS9 = 'Y')
AND (A.KEY10 IS NULL OR A.KEY10 = '*' AND REGFLAGS10 = 'Y')
AND ( ( A.PROCESSIDCODE IS NOT NULL AND UPPER(A.PROCESSIDCODE) = UPPER(B.PROCESSIDCODE) AND A.XLEVEL = B.XLEVEL AND B.ACTIVEFLAG = 'Y' )
OR ( A.RULENAME IS NOT NULL AND UPPER(A.RULENAME) = UPPER(C.RULENAME) AND A.XLEVEL = C.XLEVEL AND C.ACTIVEFLAG = 'Y' ) );
Now I want to create a function based index on the key1 column:
CREATE INDEX xib_detect_ix ON xib_detect (REPLACE(REPLACE(REPLACE(REPLACE(KEY1,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\') TABLESPACE ... ONLINE;
However, this is not working with "escape" '\', throwing: ORA-00907: missing right parenthesis
Any idea how to create an index on this construct with "escape"?
Database version is 10.2.0.3.
Thanks a lot.
Regards
OliverHi,
You can get the "missing right parenthesis" error for many different syntax errors.
In this case, you really are missing a right parenthesis. Your statement has 5 left '('s, but only 4 right ')'s. It's easy to see this if you format your code:
CREATE INDEX xib_detect_ix
ON xib_detect ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( KEY1
escape '\'
ESCAPE is an option that you can use with the LIKE operator. It gives you a mechanism for cancelling the special meaning of symbols like '%'. You're not using the LIKE operator to create the index. You're only using REPLACE, and no characters have any special meaning in REPLACE, so there's no way (or reason) to escape them. Use ESCAPE in queries that use LIKE, when appropriate. -
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 PMOnkar,
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 documentation on "How Function-Based Indexes Work" states that for the creation of a function-based index in the user's own schema, the user must be granted the QUERY REWRITE system privileges. And MUST have the following initialization parameters defined to create a function-based index:
QUERY_REWRITE_INTEGRITY set to TRUSTED
QUERY_REWRITE_ENABLED set to TRUE.
I have created a function-based unique index, which uses the SQL function DECODE(). But the user doesn't have the QUERY REWRITE sytem privilege. The user has the following privileges:
CREATE PROCEDURE
CREATE SEQUENCE
CREATE SESSION
CREATE TABLE
CREATE TRIGGER
CREATE VIEW
And also the initialization parameters for QUERY_REWRITE_INTEGRITY and QUERY_REWRITE_ENABLED are set to their DEFAULT values as follows:
QUERY_REWRITE_INTEGRITY set to ENCFORCED
QUERY_REWRITE_ENABLED set to FALSE.
Note: The index is an unique index for data integrity purpose. I am using Oracle 9.2.0.6 version.
Kindly explain me the reason how the function-based index is created without the system privilege and the initialization parmaters defined as stated in the Oracle9i Database Administrator's Guide Release 2 (9.2).You can change those parameter at session level as well.
Following link would be helpful:
http://asktom.oracle.com/pls/ask/f?p=4950:8:2552324147195810457::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:667694821129
Jaffar -
Function Based Index on Date Column
Hi All,
I need to execute a query like this :
SELECT * FROM ORDERS WHERE APPROVE_DATE IS NULL
I read anywhere that this will cause unnecessary FTS so that I should create function based index.
I have tried one below , but not sure that this is correct approach :
CREATE INDEX idx_1
ON ORDERS (NVL(APPROVE_DATE, '01-JAN-1900'));
SELECT * FROM ORDERS WHERE NVL(APPROVE_DATE, '01-JAN-1900') = '01-JAN-1900'
Is this a correct approach ?
Thank you,
xtantoA SQL_TRACE output will explain clearly what Justin has stated.
I have created a table T based on all_objects.
SQL> desc t
Name Null? Type
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME NOT NULL DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
CASE I_
SQL> select count(1) from t
2 /
COUNT(1)
934320
SQL> select count(1) from t where created is null
2 /
COUNT(1)
2376The number of null values in CREATED column is proportionately very small.
Now i execute the query without function based index.
select *
from t
where created is null
call count cpu elapsed disk query current rows
Parse 1 0.00 0.09 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 160 0.04 0.10 0 12662 0 2376
total 162 0.04 0.19 0 12662 0 2376
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
2376 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'T' (TABLE)And here is the query that uses the function based index
select *
from t
where nvl(created,to_date('01-01-1900','DD-MM-YYYY')) = to_date('01-01-1900','DD-MM-YYYY')
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 160 0.01 0.01 0 698 0 2376
total 162 0.03 0.01 0 698 0 2376
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
2376 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID) OF 'T' (TABLE)
2376 INDEX GOAL: ANALYZED (RANGE SCAN) OF 'T_FN_IDX' (INDEX)Its very obvious from the above output that the Function Based Index as increased the performance.
CASE II_
SQL> select count(1) from t
2 /
COUNT(1)
934320
SQL> select count(1) from t where created is null
2 /
COUNT(1)
202168Now the null values in the CREATED column is proportionately large than the first test case.
Now lets see without using the function based index
select *
from t
where created is null
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 13479 0.46 0.71 2 25832 0 202168
total 13481 0.46 0.71 2 25832 0 202168
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
202168 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'T' (TABLE)Now iam trying to use the function based index
select *
from t
where nvl(created,to_date('01-01-1900','DD-MM-YYYY')) = to_date('01-01-1900','DD-MM-YYYY')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 13479 0.54 0.84 0 33826 0 202168
total 13481 0.54 0.84 0 33826 0 202168
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
202168 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'T' (TABLE)Its obvious from the result that oracle has decided to go for a FULL TABLE SCAN even when an index was available.
So just having a function based index is not going to increase the query performance. There are lot of other factors to be considered as stated above.
Thanks,
Karthick. -
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 AMOraDBA02 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.
Maybe you are looking for
-
Pixelated square at start up!!!
I am having trouble with start up. Upon start up, chimes work, apple appears, then it turns to a pixelated square in the center of the screen. I have tried all suggestions. PRram reset, power management reset, squeezing the computer...nothing seems t
-
Keeps changing text tone to default
I have a a tone i got from the App store, & in settings
-
My Videos are flipping as I stroll up and down the page
Hello! FireFox... I would like to know if someone can please help me solve this problem. I'm experiencing this problem only on blogger and Word-press with my videos flipping when I scroll up and down the page. This don't occur when I use yahoo videos
-
Reading valueset of a mapped Simple Type
Hi, We have a attribute coming from a model. This attribute is of a simple type format. we have a scenario where we have to read the number of values in the enumeration of the simple type. Since its mapped , it a modifiablesimpletype could not be ob
-
I have 300gb of music on one external hard drive. I noticed that when I take one of my albums and Add To Library it will not only import my songs into iTunes but it will also make a duplicate folder of my album in the iTunes Music folder. I am assumi