Function-Based Indexes (FBI) on Linux and Solaris
I have a question about FBI on different systems (Linux and Solaris).
---- Oracle on Linux -----
SQL> CREATE TABLE T_DUMMY(NAME VARCHAR(20));
Table created.
SQL> CREATE INDEX T_DUMMY_IDX ON T_DUMMY(UPPER(NAME));
Index created.
However, when I do the same on the Oracle running on Solaris, I get the following error:
---- Oracle on Solaris -----
SQL> CREATE TABLE T_DUMMY(NAME VARCHAR(20));
Table created.
SQL> CREATE INDEX T_DUMMY_IDX ON T_DUMMY(UPPER(NAME));
CREATE INDEX T_DUMMY_IDX ON T_DUMMY(UPPER(NAME))
ERROR at line 1:
ORA-01031: insufficient privileges
I know that I have to add "QUERY REWRITE" in order to create a FBI. However, why Oracle on Linux behave differently. Would it be any difference/problem if I do NOT add "QUERY REWRITE" for Oracle on Linux (For example, would the EXPLAIN PLAN different)?
general user settings are the same (privilege, role) Well, the specific settings must be different. I would check to see whether one of the roles has been granted the QUERY REWRITE system privilege on your Linux instance but not on Solaris.
Cheers, APC
Similar Messages
-
FUNCTION-BASED INDEX ( ORACLE 8I NEW FEATURE )
제품 : ORACLE SERVER
작성날짜 : 2004-08-16
FUNCTION-BASED INDEX ( ORACLE 8I NEW FEATURE )
==============================================
SCOPE
10g Standard Edition(10.1.0) 이상 부터 Function-based Index 기능이 지원된다.
Explanation
1. 개요
Function-based index는, 함수(function)이나 수식(expression)으로 계산
된 결과에 대해 인덱스를 생성하여 사용할 수 있는 기능을 제공한다.
질의 수행 시 해당 함수나 수식을 처리하여 결과를 가져 오는 것이 아니라,
인덱스 형태로 존재하는 미리 계산되어 있는 결과를 가지고 처리하므로
성능 향상을 기할 수 있다.
2. 제약사항
1) aggregate function 에 대한 function-based index 생성 불가.
(예 : sum(...) )
2) LOB, REF, nested table 컬럼에 대한 function-based index 생성 불가.
3. 주요 특징
1) cost-based optimizer에 의해 사용됨.
2) B*Tree / bitmap index로 생성 가능.
3) 산술식 (arithmetic expression), PLSQL function, SQL built-in
function 등에 적용 가능.
4) 함수나 수식으로 처리된 결과에 대한 range scan 가능
5) NLS SORT 지원
6) SELECT/DELETE를 할 때마다 함수나 수식의 결과를 계산하는 것이 아니라
INSERT/UPDATE 시 계산된 값을 인덱스에 저장.
7) 질의 속도 향상
8) object column이나 REF column에 대해서는 해당 object에 정의된
method에 대해 function-based index 생성 가능.
4. 생성 방법
CREATE [UNIQUE | BITMAP ] INDEX <index_name>
ON <tablename> (<index-expression-list>)
<index-expression-list> -> { <column_name> | <column_expression> }
예) CREATE INDEX EMP_NAME_INDEX ON EMP (UPPER(ENAME));
CREATE INDEX EMP_SAL_INDEX ON EMP( SAL + COMM, empno);
* Function-based index를 생성하기 위해서는 QUERY REWRITE 권한이
부여 되어 있어야만 한다.
예) GRANT QUERY REWRITE TO SCOTT;
5. Function-Based Index 사용을 위한 사전 작업
1) Function-based index는 cost based optimizer에서만 사용 가능하므로,
테이블에 대해 미리 analyze 해 주는 것이 바람직하다.
그리고 init 파일에서 OPTIMIZER_MODE 를 FIRST_ROWS 나 ALL_ROWS 등으
로 지정하거나 HINT 등을 사용하여 cost based optimizer가 사용되도록
한다.
2) init 파일에서 COMPATIBLE 파라미터 값을 8.1 이상으로 설정되어 있어야
한다.
( 예 : COMPATIBLE = 8.1.6 )
3) session/instance level 에서 QUERY_REWRITE_ENABLED 값이 TRUE 지정
되어 있어야 한다.
( 예 : ALTER SESSION SET QUERY_REWRITE_ENABLED = TRUE; )
6. 예제
1) init 파라미터에서 다음과 같이 지정
compatible = 8.1.6 (반드시 8.1이상이어야 한다)
query_rewrite_enabled = true
query_rewrite_integrity = trusted
2) SCOTT 유저에서 function_based_index 생성
create index idx_emp_lower_ename
on emp
( lower(ename) ) ;
3) EMP table analyze
analyze table emp compute statistics ;
4) PLAN_TABLE 생성
@ ?/rdbms/admin/utlxplan.sql
5) Cost based optimizer 선택
alter session set optimizer_mode = FIRST_ROWS ;
6) Query 실행
explain plan set statement_id='qry1' FOR
select empno, ename
from emp
where lower(ename) = 'ford' ;
7) PLAN 분석
SELECT LPAD(' ',2*level-2)||operation||' '||options||' '||object_name query_plan
FROM plan_table
WHERE statement_id='qry1'
CONNECT BY prior id = parent_id
START WITH id = 0 order by id ;
-> 결과
QUERY_PLAN
SELECT STATEMENT
TABLE ACCESS BY INDEX ROWID EMP
INDEX RANGE SCAN IDX_EMP_LOWER_ENAME
7. 결론
Function-based index는 적절하게 사용될 경우 성능상의 많은 이점을 가져
온다. Oracle8i Designing and Tuning for Performance에서도 가능한 한
Function-based index를 사용하는 것을 권장하고 있으며, LOWER(), UPPER()
등의 함수를 사용하여 불가피하게 FULL TABLE SCAN을 하는 경우에 대해서도
효과적으로 처리해 줄 수 있는 방안이라 할 수 있다.
Reference Documents
-------------------Partha:
From the Oracle8i Administrators Guide:
"Table owners should have EXECUTE privileges on the functions used in function-based indexes.
For the creation of a function-based index in your own schema, you must be
granted the CREATE INDEX and QUERY REWRITE system privileges. To create
the index in another schema or on another schemas tables, you must have the
CREATE ANY INDEX and GLOBAL QUERY REWRITE privileges."
Hope this helps.
Peter -
Function based indexing v8.1.7 not working
I have created a function based index on a column and when I run my query although I get the correct results I seem to be doing a full table scan instead of using the index.
Are there any known bugs or additional parameter setting for function based indexing in 8i ?
Thanks
Bob IRobert
To use Functional Index you to set following parameters in INIT.ORA, Compatiable should be more than 8.1.0
query_rewrite_enabled = TRUE
query_rewrite_integrity = TRUSTED
Compatiable = 8.1.7.0
optimizer = Choose
Create index indexname on table (lower(column));
then analyze table
Analyze table tablename compute statistics;
Regards
Shailesh
null -
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 -
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. -
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?
Thankscheck 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 -
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. -
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 -
Query Transformation in Function Based Index's Expression
Hi All,
I am having a wired issue with Function Based Indexes on Orcale 10.2.0.3 running on Solaris 5.9.
I have created two FBI on two tables using following syntax.
CREATE INDEX EQHUB.IDX_BBO_WRT_DES_FBI ON EQHUB.BBO_WARRANT_PRICING (CASE WHEN latest_version_flag = 'Y' THEN 1 ELSE NULL END);
CREATE INDEX EQHUB.IDX_BBO_DES_FBI ON EQHUB.BBO_DESCRIPTIVE_DATA (CASE WHEN latest_version_flag = 'Y' THEN 1 ELSE NULL END);
For the second command (IDX_BBO_DES_FBI), when i query DBA_IND_EXPRESSIONS view, i found that Oracle has done some kind of QUERY TRANSFORMATION (?) and converted
FBI expression to CASE "LATEST_VERSION_FLAG" WHEN 'Y' THEN 1 ELSE NULL END.At the same time,EXPRESSION on first index is not changed.
Now,my question is what has made transformation to occure only for second index.
I also found that inspite of highly SELECTIVE nature of both the indexes, only SECOND index is being used by CBO (for which trasnformation occured)
and IDX_BBO_WRT_DES_FBI is not being used(FTS is happening instead).
Query is using same expression for both the tables as
(CASE WHEN latest_version_flag = 'Y' THEN 1 ELSE NULL END)=1
INDEX_NAME TABLE_NAME COLUMN_EXPRESSION
IDX_BBO_WRT_DES_FBI BBO_WARRANT_PRICING CASE WHEN "LATEST_VERSION_FLAG"='Y' THEN 1 ELSE NULL END
IDX_BBO_DES_FBI BBO_DESCRIPTIVE_DATA CASE "LATEST_VERSION_FLAG" WHEN 'Y' THEN 1 ELSE NULL ENDI read that expression should be evaluated including CASE of characters and spaces in query.Is that true?
Appreciating responses in advance.Randolf.
It's a shame that I forgot to look into the full execution plan information to check how Oracle really handles my queries.
Look here(edited for clarity):
explain plan for
select /*+ case1 ordered use_nl(x, y) */ count(case c1
when '1' then 1
when '2' then 2
when '3' then 3
else 4
end) from
(select level from dual connect by level <= 300000) x,
(select
from t1
) y;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
| 2 | NESTED LOOPS | | 3 | 6 | 5 (0)| 00:00:01 |
| 3 | VIEW | | 1 | | 2 (0)| 00:00:01 |
| 4 | CONNECT BY WITHOUT FILTERING| | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | T1 | 3 | 6 | 3 (0)| 00:00:01 |
Column Projection Information (identified by operation id):
1 - (#keys=0) COUNT(CASE WHEN "T1"."C1"='1' THEN 1 WHEN "T1"."C1"='2' THEN
2 WHEN "T1"."C1"='3' THEN 3 ELSE 4 END )[22]
2 - (#keys=0) "T1"."C1"[CHARACTER,1]
4 - "DUAL".ROWID[ROWID,10], LEVEL[4]
5 - "DUAL".ROWID[ROWID,10]
6 - "T1"."C1"[CHARACTER,1]
32 rows selected.
explain plan for select /*+ case2 ordered use_nl(x, y) */ count(case
when c1 = '1' then 1
when c1 = '2' then 2
when c1 = '3' then 3
else 4
end) from
(select level from dual connect by level <= 300000) x,
(select
from t1
) y;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
| 2 | NESTED LOOPS | | 3 | 6 | 5 (0)| 00:00:01 |
| 3 | VIEW | | 1 | | 2 (0)| 00:00:01 |
| 4 | CONNECT BY WITHOUT FILTERING| | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | T1 | 3 | 6 | 3 (0)| 00:00:01 |
Column Projection Information (identified by operation id):
1 - (#keys=0) COUNT(CASE WHEN "T1"."C1"='1' THEN 1 WHEN "T1"."C1"='2' THEN
2 WHEN "T1"."C1"='3' THEN 3 ELSE 4 END )[22]
2 - (#keys=0) "T1"."C1"[CHARACTER,1]
4 - "DUAL".ROWID[ROWID,10], LEVEL[4]
5 - "DUAL".ROWID[ROWID,10]
6 - "T1"."C1"[CHARACTER,1]As you exactly mentioned, I was executing different SQL but actually same queries!
Thanks for pointing my flaws.
PS) OP, forgive me for bothering you with off-topic things. :)
================================
Dion Cho - Oracle Performance Storyteller
http://dioncho.wordpress.com (english)
http://ukja.tistory.com (korean)
================================
Edited by: Dion_Cho on Feb 10, 2009 5:45 AM
Typo -
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. -
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 -
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. -
ORA-00439 while creating function based indexes.
Hi everybody
I'm working on Oracle 8.1.7 database, and try to create a function based index on a table.
Unfortunately I get the ORA-00439 error, that recommends me not to use this feature :-(
What should I do to activate this feature ?
ThanxTry.
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bi
PL/SQL Release 10.1.0.2.0 - Production
CORE 10.1.0.2.0 Production
TNS for Solaris: Version 10.1.0.2.0 - Production
NLSRTL Version 10.1.0.2.0 - Production
Maybe you are looking for
-
Exporting a playlist and displaying song length of time
I tried exporting a song list as a text file from iTunes and opened it up in Excel. The format for length of time of a song is altered. Rather than displayed as 2:30 for example it gives you a series of numbers. It looks as if it gives you the number
-
Remove distortion from mic too close to mouth?
Are there any recommended settings for removing the fuzziness from a tape recording (talking narration), where the person is has the mic too close or is too loud for it or both? The voice is pretty clear but the high pass filters aren't quite removin
-
Field lables changes in ESS iView not reflected on portal
Hi All, I am trying to customize the SAP ESS Address DC (webdynpro Java) for South Africa region as per the SAP OSS note (No: 1428933). In order to incorporate the changes I have imported the ess/za/addr DC into NWDS. I have changed the label text as
-
Why is clone brush slowing and lagging?
Before I explain my Lightroom issue, I want to describe my hardware platform because it may be relevant to solving my problem. Asus P5B Deluxe motherboard Intel Core 2 Duo E8400 3.0 mghz cpu 8 gigs Corsair ram New Invidia EGVA GeForce 750 Ti with 2 g
-
Binding parameters lost after exporting OWB
Binding parameters lost in Process Flow after exporting. So each time when do the importing, I have to run a OMB scrits with OMBALTER as a patch to amend . Thanks,