INTERMEDIA TEXT INDEX를 사용하는 QUERY의 TUNING
제품 : ORACLE SERVER
작성날짜 : 2002-04-12
INTERMEDIA TEXT INDEX를 사용하는 QUERY의 TUNING
===============================================
Purpose
Intermedia text를 사용하는 query의 속도를 향상시킬 수 있는 방안을
알아보자.
Explanation
1. Make analyze all the table in the query
text index를 이용하는 Query 안의 모든 Table을 analyze 해 주십시요.
예를 들어 다음의 command를 이용할 수 있습니다.
ANALYZE TABLE <table_name> COMPUTE STATISTICS;
or
ANALYZE TABLE <table_name> ESTIMATE STATISTICS 1000 ROWS;
or
ANALYZE TABLE <table_name> ESTIMATE STATISTICS 50 PERCENT;
2. Using FIRST_ROWS hint
더 좋은 response time 을 위해서 first_rows hint 를 사용해 보십시요.
database에 기본적으로 설정된 optimizer mode는 choose mode입니다.
이것은 전체 처리시간(throughput)을 가장 빠르게 하기 위한(all_rows mode)
plan을 따르기 때문에 user의 입장에서는 first_rows 보다는 늦다고 느낄 수
있습니다.
Query에 다음과 같이 hint를 주고 performance를 확인해 보십시요.
select /*+ FIRST_ROWS */ pk, col from ctx_tab
where contains(txt_col, 'test', 1) > 0;
단, first_rows hint를 이용하는 경우 자동으로 score 순서대로
ordering 되지 않습니다. 왜냐하면 단어에 부합하는 문서를 찾는대로
즉시 결과로 나타내 주기 때문입니다.
3. Make sure text index is not fragmented
insert, delete 가 많이 되는 table의 경우 index fragment를 제거해 주어야
합니다. Index fragmentation 은 다음과 같이 확인할 수 있습니다.
select count(*) from dr$<indexname>$i; -> A
select count(*) from (select distinct(token_text) from dr$<indexname>$i); -> B
위의 결과가 A/B 의 값이 3:1 보다 크면 optimize_index 를 실행해 주시는
것이 좋습니다. 다음과 같은 command로 index optimization을 할 수 있습니다.
alter index <index_name> rebuild online
parameters('optimize full unlimited');
index rebuild중에 online option을 주면 rebuild하는 중에도 계속 index를
사용할 수 있게 됩니다. 하지만, 가능하면 사용자가 없을 때 rebuild하는 것이
좋습니다.
4. Check execution plan and sql trace.
기본적인 여러 가지 작업들에도 속도가 별로 향상되지 않는다면, 직접
sql trace를 떠서 Execution plan등을 확인해 보는 것이 필요합니다.
예를 들어 SQL*PLUS에서 다음과 같이 sql trace를 뜹니다.
alter session set timed_statistics=true;
alter session set sql_trace=true;
select ..... -> execute the query
실행 후,
exit
user_dump_dest 에 지정된 directory에 trace 가 떨어지면 다음과 같은
command로 tkprof 를 떠서 내용을 확인합니다.
$ tkprof <tracefilename> <outputfilename> explain=username/password
Referenc Documents
Bulletin#10134 : SQL trace와 tkprof 사용 방법
Similar Messages
-
Exchange Server Information Store has encountered an error while executing a full-text index query
Hi Team need help
Exchange 2013 EAC doesnt show the databases and it gives message
"Your request couldn't be completed. Please try again in a few minutes."
Its a 9 Node DAG and I stopped and diabled Search and Search Host controller on all of them
in the event viewer see a lot of Event id 1012
Log Name: Application
Source: MSExchangeIS
Date: 4/1/2013 9:23:48 AM
Event ID: 1012
Task Category: General
Level: Error
Keywords: Classic
User: N/A
Computer: ex1301.dagdc.com
Description:
Exchange Server Information Store has encountered an error while executing a full-text index query ("and(or(itemclass:string("IPM.Note*", mode="and"), itemclass:string("IPM.Schedule.Meeting*", mode="and"), itemclass:string("IPM.OCTEL.VOICE*",
mode="and"), itemclass:string("IPM.VOICENOTES*", mode="and")), subject:string("SearchQueryStxProbe*", mode="and"), folderid:string("48A300C7FBA4DA408B80EB019A1CE94900000000000E0000"))"). Error
information: System.TimeoutException: Failed to open a channel.
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteServiceCall(IProcessingEngineChannel& serviceProxy, Action`1 call, Int32 retryCount)
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteSearchFlow(String flowName, Dictionary`2 inputData)
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.<ExecuteInternal>d__18.MoveNext()
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.<ExecuteSimple>d__a.MoveNext()
at Microsoft.Exchange.Server.Storage.FullTextIndex.FullTextIndexQuery.ExecutePagedFullTextIndexQuery(Guid databaseGuid, Guid mailboxGuid, Int32 mailboxNumber, String query, CultureInfo culture, Guid correlationId, QueryLoggingContext loggingContext,
PagedQueryResults pagedQueryResults)
at Microsoft.Exchange.Server.Storage.StoreCommonServices.StoreFullTextIndexHelper.ExecuteFullTextIndexQuery(Context context, MailboxState mailboxState, QueryParameters queryParameters, PagedQueryResults pagedQueryResults, ExchangeId searchFolderId,
SearchExecutionDiagnostics diagnostics)
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="MSExchangeIS" />
<EventID Qualifiers="49156">1012</EventID>
<Level>2</Level>
<Task>1</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2013-04-01T16:23:48.000000000Z" />
<EventRecordID>192599</EventRecordID>
<Channel>Application</Channel>
<Computer>ex1301.dagdc.com</Computer>
<Security />
</System>
<EventData>
<Data>and(or(itemclass:string("IPM.Note*", mode="and"), itemclass:string("IPM.Schedule.Meeting*", mode="and"), itemclass:string("IPM.OCTEL.VOICE*", mode="and"), itemclass:string("IPM.VOICENOTES*",
mode="and")), subject:string("SearchQueryStxProbe*", mode="and"), folderid:string("48A300C7FBA4DA408B80EB019A1CE94900000000000E0000"))</Data>
<Data>System.TimeoutException: Failed to open a channel.
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteServiceCall(IProcessingEngineChannel& serviceProxy, Action`1 call, Int32 retryCount)
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.ExecuteSearchFlow(String flowName, Dictionary`2 inputData)
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.<ExecuteInternal>d__18.MoveNext()
at Microsoft.Exchange.Search.OperatorSchema.PagingImsFlowExecutor.<ExecuteSimple>d__a.MoveNext()
at Microsoft.Exchange.Server.Storage.FullTextIndex.FullTextIndexQuery.ExecutePagedFullTextIndexQuery(Guid databaseGuid, Guid mailboxGuid, Int32 mailboxNumber, String query, CultureInfo culture, Guid correlationId, QueryLoggingContext loggingContext,
PagedQueryResults pagedQueryResults)
at Microsoft.Exchange.Server.Storage.StoreCommonServices.StoreFullTextIndexHelper.ExecuteFullTextIndexQuery(Context context, MailboxState mailboxState, QueryParameters queryParameters, PagedQueryResults pagedQueryResults, ExchangeId searchFolderId,
SearchExecutionDiagnostics diagnostics)</Data>
<Binary>5B444941475F4354585D000084000000FF09000000000000000268000000808A00100000000080CA00100000000080B200100000000080D200100000000030FF001000000000309F00100000000030DF001000000000B09D001000000000B0DD001000000000B0ED001000000000B08D001000000000B095001000000000B0A5001000000000</Binary>
</EventData>
</Event>Hi,
Please reenable and start the search engine service and try again.
The simillar case for your reference:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrgeneral/thread/4f43ef50-b71f-4ab3-8ced-70f1c36c5509
Hope it is hlepful.
Fiona Liao
TechNet Community Support -
Strange: Conditional Error in Intermedia Text Index Creation
Hi All,
I am facing a strange error while creating the Intermedia Text index on 8.1.6 release for NT 4.0.
I have one database instance installed on the server. When i connect to Oracle through SQL plus as: connect username/password;
The index creation works fine!
But, if i connect using: username/password@servicename;
The index creation does not work!
The following error occurs.
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000:intermedia Text error:
ORA-50704:Net8 listener is not running or cannot start external procedures
ORA-28575:unable to open RPC connection to external procedure agent
ORA-12154:TNS:could not resolve service name
ORA-06512:at "CTXSYS.DRUE", line 126
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 54
ORA-06512:at line 1
Could anyone please help as to why it works without when connected without the service name but not otherwise?
Thanking you in advance!
Thanks and Regards
Anurag AgarwalHi All,
I am facing a strange error while creating the Intermedia Text index on 8.1.6 release for NT 4.0.
I have one database instance installed on the server. When i connect to Oracle through SQL plus as: connect username/password;
The index creation works fine!
But, if i connect using: username/password@servicename;
The index creation does not work!
The following error occurs.
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000:intermedia Text error:
ORA-50704:Net8 listener is not running or cannot start external procedures
ORA-28575:unable to open RPC connection to external procedure agent
ORA-12154:TNS:could not resolve service name
ORA-06512:at "CTXSYS.DRUE", line 126
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 54
ORA-06512:at line 1
Could anyone please help as to why it works without when connected without the service name but not otherwise?
Thanking you in advance!
Thanks and Regards
Anurag Agarwal -
Creating intermedia text index error
Hello. I tried creating an index using the below command
create index mydocs_text_index on
mydocs(thefile) indextype is ctxsys.context;
However, I received some error message as follows:
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000: file not found
DRG-50704: file not found
ORA-28575: unable to open RPC connection to external procedure agent
ORA-06512: at "CTXSYS.DRUE", line 126
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 54
ORA-06512: at line 1
What do you think is wrong?
Thank youIs the listener up and running?
Installation
1.What are the steps to install interMedia Text manually, AFTER installing the code via the
installer?
A.
cd $ORACLE_HOME/ctx/admin
B. as SYS:
@dr0csys.sql ctxsys system temp
where ctxsys is the ctxsys password
system is the default tablespace for ctxsys
temp is the temporary tablespace for ctxsys
C. as CTXSYS:
@dr0inst.sql
/oracle/db/dev118/ctx/lib/libctxx8.so
(on Solaris)
where /oracle/db/dev118 is $ORACLE_HOME
D. as CTXSYS:
@defaults/drdefus.sql
Note: this is assuming you want U.S. to be your language default, otherwise run the
corresponding drdef for your language.
2.What are the steps to install interMedia Text manually, with a Net8 Configuration?
A. Configure an IPC listener address.
For example, change:
LISTENER =
(ADDRESS_LIST=
(ADDRESS=
(PROTOCOL=tcp) (HOST=ap118sun.us.oracle.com) (PORT=1521)
to:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC0))
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = ap118sun) (PORT
=1521))
This shows the full LISTENER definition in your listener.ora. Note: EXTPROC0 ends in a
zero.
B. Add a system identifier (SID) name of PLSExtProc and a program name of EXTPROC in the server's LISTENER.ORA file.
For example, in the SID_LIST_LISTENER definition, insert:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC = ...
(SID_DESC =
(SID_NAME=PLSExtProc)(ORACLE_HOME=/oracle/db/dev118)
(PROGRAM=extproc)
C. Add a net service name description entry for EXTPROC0 in the server's tnsnames.ora
file, using SID rather than SERVICE_NAME in the CONNECT_DATA section.
For example, add this to the end of tnsnames.ora:
extproc_connection_data =
(DESCRIPTION=
(ADDRESS_LIST =
(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
(CONNECT_DATA=
(SID=PLSExtProc)
(PRESENTATION = RO)
This entry should be added exactly as you see it here (do NOT substitute your SID
anywhere, do NOT change the case of any text). Note: EXTPROC0 ends in a zero, RO
ends in an Oh
1.How do I check my interMedia Text installation and setup?
A.
lsnrct1status
should give you the following:
LSNRCTL for Solaris: Version
8.1.5.0.0 - Production on 31-MAR-99 18:57:49
(c) Copyright 1998 Oracle Corporation. All rights reserved.
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for Solaris: Version 8.1.5.0.0 - Production
Start Date 30-MAR-99 15:53:06
Uptime 1 days 3 hr. 4 min. 42 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File
/private7/oracle/oracle_home/network/admin/listener.ora
Listener Log File
/private7/oracle/oracle_home/network/log/listener.log
Services Summary...
PLSExtProc has 1 service handler(s)
oco815 has 3 service handler(s)
The command completed successfully
The important information to understand here is the service handler for PLSExtProc.
B. Create a user/table/index/query thus:
As SYS or SYSTEM:
create user ctxtest identified by ctxtest ;
grant connect, resource, ctxapp to ctxtest ;
Do any other grants, quotas, tablespace etc. for the new user. As CTXTEST:
create table quick
quick_id number primary key,
text varchar(80)
insert into quick ( quick_id, text )
values ( 1, 'The cat sat on the mat' );
insert into quick ( quick_id, text )
values ( 2, 'The quick brown fox jumped over the lazy dog' );
commit;
create index quick_text on quick ( text )
indextype is ctxsys.context;
At this point, if your Net8 setup is NOT correct you will get:
create index quick_text on quick ( text )
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000: ConText error:
DRG-50704: Net8 listener is not running or cannot start external procedures
ORA-28575: unable to open RPC connection to external procedure agent
ORA-06512: at "CTXSYS.DRUE", line 122
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 34
ORA-06512: at line 1
If everything is OK, you will get:
Index created.
Now try some queries:
SQL> select quick_id from quick where contains(text, 'cat')>0;
QUICK_ID
1
SQL> select quick_id from quick where contains(text, 'fox')>0;
QUICK_ID
2
Congratulations !! You now have a successful interMedia Text V8.1 installation.
null -
Hello
Had a query on oracle Text Index.
1. I have created a table with column ID as sequence & column description as Varchar2(500)
2. Inserted 3 records
3. I created the Oracle Text index on column "description" as INDEXTYPE IS CTXSYS.CONTEXT
4. Run a select using "contains" , get the records as required.
5. I insert another new record & commit;
6. Run the same old query using contains but for the new records I get 0 records
7. Drop the Index and Recreate the index using same old index on column "description" as INDEXTYPE IS CTXSYS.CONTEXT
8. Run the same old query using contains but for the new records and now I get the records as required.
Does that mean every time I insert new records I have to rebuild the Oracle Text Index ?
Your Help will be much appreciated
Regards
HarshadYou need to use some method of updating your index. You can drop and recreate or you can rebuild or you can use ctx_ddl.sync_index or you can include sync(on commit) in your parameters when you create the index or various other methods of periodic synchronization and optimization.
-
InterMedia Text indexing error - can't open files
I am getting the following error on 3 of 4 files for which I am trying to set up a simple text index:
DRG-11101: failed to open file \drgit3
Here are the steps/cmds I followed:
begin
ctx_ddl.create_preference('tracker_file_datastore','FILE_DATASTORE');
ctx_ddl.set_attribute('tracker_file_datastore','PATH','d:\temp\pptd\doc');
end;
create index doc_index on document(qualified_file_name)
indextype is ctxsys.context parameters ('datastore TRACKER_FILE_DATASTORE lexer TRACKER_LEXER')
The table "document" contains an id column and a text column called "qualified_file_name". Qualified_file_name contains the full path and file name ("d:\temp\pptd\doc\1.doc", etc.)
I am running Oracle 8.1.6 with InterMedia installed on NT 4.0. I have also tried to run the filter program ctxhx, but it only produces a zero length text file. Ctxhx is also very sporadic in that it does not always create an output file (buggy???).
The error documentation does not give any helpful suggestions for resolving this problem. The cause is: failed to open a file. The action is: check whether file exist or access permission available. I checked both.
Any suggestions would be greatly appreciated.<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Mike Verdugo ([email protected]):
I am getting the following error on 3 of 4 files for which I am trying to set up a simple text index:
DRG-11101: failed to open file \drgit3
Here are the steps/cmds I followed:
begin
ctx_ddl.create_preference('tracker_file_datastore','FILE_DATASTORE');
ctx_ddl.set_attribute('tracker_file_datastore','PATH','d:\temp\pptd\doc');
end;
create index doc_index on document(qualified_file_name)
indextype is ctxsys.context parameters ('datastore TRACKER_FILE_DATASTORE lexer TRACKER_LEXER')
The table "document" contains an id column and a text column called "qualified_file_name". Qualified_file_name contains the full path and file name ("d:\temp\pptd\doc\1.doc", etc.)
I am running Oracle 8.1.6 with InterMedia installed on NT 4.0. I have also tried to run the filter program ctxhx, but it only produces a zero length text file. Ctxhx is also very sporadic in that it does not always create an output file (buggy???).
The error documentation does not give any helpful suggestions for resolving this problem. The cause is: failed to open a file. The action is: check whether file exist or access permission available. I checked both.
Any suggestions would be greatly appreciated.<HR></BLOCKQUOTE>
I forgot to mention that the file types are Microsoft Word documents (both Win 2000 and 97). -
Intermedia text index creation error
My intermedia text was working fine, but now when create one index, it failed and it gave me the following error message:
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000: ConText error:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: ld.so.1: extprocPLSExtProc: fatal: libskgxp8.so: open failed: No such file or directory
ORA-06512: at "CTXSYS.DRUE", line 122
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 34
ORA-06512: at line 1
The listener itself is fine, is it because some library need to be re-created?
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Alexander Bogomolov ([email protected]):
I've installed Intermedia text. During sample index creation i've get following error messages:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: Unable to load DLL
ORA-06512: at "CTXSYS.DRUE", line 126
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 54
ORA-06512: at line 1...
seems to be incorrect NET8 settings. How can I solve this problem?
thanks.
Sorry for bad English. regards!<HR></BLOCKQUOTE>
*** check your listener.ora file
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = oracle_home)
(PROGRAM = extproc)
(SID_DESC =
(GLOBAL_DBNAME = global dbname)
(ORACLE_HOME = oracle_home)
(SID_NAME = sidname)
for the correct location of extproc
null -
Errors reading documents when creating intermedia text indexs;
The populating progress ended normally without error message . I check the log and found some reading errors happens during populating progress.
The log is:
12:56:45 07/19/00 begin logging
12:56:58 07/19/00 populate index: CS.CTX_ADDRESS
12:56:58 07/19/00 Begin document indexing
12:56:58 07/19/00 100 documents indexed
12:56:58 07/19/00 200 documents indexed
12:56:58 07/19/00 300 documents indexed
12:56:58 07/19/00 Errors reading documents: 0
12:56:58 07/19/00 Index data for 342 documents to be written to database
12:56:58 07/19/00 memory use: 305012
12:56:58 07/19/00 index data written to database.
12:56:58 07/19/00 End of document indexing. 342 documents indexed.
Only 1 percente of all rows are populated.
Somebody help me!!!How many rows in your $I?
Which rows are not being populated? -
InterMedia Text with USER_DATASTORE and ORA-03113
Hi,
I have problems using Oracle's InterMedia Text-index with a
USER_DATASTORE. I'm using Oracle 8.1.7 on Windows NT 4.0.
What I try to do is to create a context-index on multiple columns
of multiple tables. I created a table containing the original
tablenames and primary keys plus a char(1)-column to index, a
user_datastore, a procedure in a user-schema, a
wrapping-procedure in ctxsys' schema and finally the index. All
works fine so far but I get an ORA-03113 "end-of-file on
communication channel" error when querying the table with
contains. The procedure itself works.
Here's what I tried in detail:
I created a table "alldocs" containing the tablename and
primary-key-value of each line of each table plus a dummy-column
for the index:
create table alldocs(
table varchar2(30) not null,
id number not null,
data char(1),
primary key(tabelle, id)
I filled this table:
insert into alldocs (select 'MYDOCS', id, 'a' from mydocs);
insert into alldocs (select 'OTHERDOCS', id, 'b' from otherdocs);
The user's procedure - only dummy for testing - is:
create procedure test.GetAllDocsData(row IN ROWID, data IN OUT
NOCOPY CLOB) IS
tabname varchar2(30);
myid number;
tmpclob clob;
begin
dbms_lob.createtemporary(tmpclob, TRUE);
dbms_lob.writeappend(tmpclob, 34, 'Ein Text mit ca. 20
Zeichen Ldnge.');
data := tmpclob;
end;
In ctxsys' schema I defined the following procedure and the
datastore:
create or replace procedure sysGetAllDocsData(rid in rowid, tlob
in out clob) is
begin
test.GetAllDocsData(rid, tlob);
end sysGetAllDocsData;
grant execute on sysGetAllDocsData to test;
call ctx_ddl.create_preference('MyUserDS', 'user_datastore');
call ctx_ddl.set_attribute('MyUserDS', 'procedure',
'sysGetAllDocsData');
call ctx_ddl.set_attribute('MyUserDS', 'output_type', 'CLOB');
Finally I defined the index:
create index test.alldocs_ctx on test.alldocs(data)
indextype is ctxsys.context
parameters ('DATASTORE CTXSYS.MyUserDS FILTER
CTXSYS.INSO_FILTER LEXER BASIC_LEXER');
This all works without errors. But when querying like this:
select * from test.alldocs where contains('data', 'Text')>0
the answer is
ORA-03113: end-of-file on communication channel
I hope someone can help.
Greetings
RalfHi Ralf,
please define first your own preferences like this:
exec CTX_DDL.drop_preference('MY_LEXER');
exec CTX_DDL.create_preference('MY_LEXER','BASIC_LEXER');
exec CTX_DDL.set_attribute('MY_LEXER','ALTERNATE_SPELLING',
'GERMAN');
exec CTX_DDL.set_attribute('MY_LEXER','BASE_LETTER','YES');
exec CTX_DDL.set_attribute('MY_LEXER','MIXED_CASE', 'NO');
exec CTX_DDL.set_attribute('MY_LEXER','INDEX_THEMES','NO');
exec CTX_DDL.set_attribute('MY_LEXER','INDEX_TEXT', 'YES');
exec CTX_DDL.set_attribute('MY_LEXER','COMPOSITE', 'GERMAN');
exec ctx_ddl.Drop_Preference ('MY_FILTER');
exec ctx_ddl.Create_Preference ('MY_FILTER','NULL_FILTER');
exec ctx_ddl.drop_section_group ('MY_SECTION');
exec ctx_ddl.create_section_group
('MY_SECTION','NULL_SECTION_GROUP');
and then create your index with this preferences. You only need
an INSO filter if you want to index pdf,word,...
create index test.alldocs_ctx on test.alldocs(data)
indextype is ctxsys.context
parameters ('DATASTORE CTXSYS.MyUserDS FILTER
CTXSYS.INSO_FILTER LEXER BASIC_LEXER');create index test.alldocs_ctx on test.alldocs(data)
indextype is ctxsys.context
parameters ('
DATASTORE CTXSYS.MyUserDS
lexer MY_LEXER
filter MY_FILTER
section group MY_SECTION');
Then see in the token table what tokens are in the index:
select token_text from dr$alldocs_ctx$i;
If you got also an ORA-3113 see in alert.log if there is a trace
referenced with this error and have a look in this file to find a
better error message.
Good luck.
Thomas -
Hi, there,
I am using interMedia text to query XML document, which is stored in Oracle 8i as one column of CLOB.
I want to extend the functionality of interMedia text, how can I do it? e.g. nested WITHIN is not allowed in 8.1.5. How can I write another operator to do nested WITHIN? (8.1.6 has the nested WITHIN, but if want write my own version of similar operator for query, can I do it?)
Thank in advance!
HonglinIs there any procedure to write code to extend query functionality in interMedia text? To write my own version of operator WITHIN, can you tell me the guideline to leverage extensibility or data cartridge framework?
Thanks a lot!
Honglin -
Query tuning and using the "better" index.
I have a database table with about 40,000 records in it. Using
a certain index first limits the number of rows to 11,000
records. Using a different index first (by disabling the other
index in the query) limits the number of rows to 2,500 records.
Using the explain plan, the rest of the query is parsed the same
way for both queries. What reasons can explain why when the
index that returns 11,000 records first runs faster than
the "better" index? I thought the whole idea behind query
tuning is to use the index that limits the data the most.It looks like Oracle likes the equality condition more than the greater than -less than combination (which you might like to recode as a BETWEEN condition for clarity).
There are a number of factors here.
i) Are the "test names" equally distributed? Do some test names appear with greater frequency than others? If so, collecting column statistics might cause the BATCH_2 index to be used for some test names, and not for others.
ii) Likewise, what is the distribution of cdates? How does the distribution of cdates vary by test name?
iii) You could force the use of the BATCH_6 index over the BATCH_2 by using an optimizer hint instead of dropping the BATCH_2 index ...
select /*+ index(batch batch_6) */ id, test, cdate
from batch
where test = 'Some test name'
and cdate >= &start date&
and cdate < &end date& + 1
... or even try prompting Oracle to use both indexes ...
select /*+ index(batch batch_6) index(batch batch_2) */ id, test, cdate
from batch
where test = 'Some test name'
and cdate >= &start date&
and cdate < &end date& + 1
... and test the response times, then chose to use the optimizer hint in your application
iv) You might like to replace the rather unselective BATCH_2 index with a BATCH_2_6 index on both test and cdate (in that order). That would probably give you an excellent result, and the BATCH_6 index can still be used to satisfy queries slective on cdate that are not selective on test (in very recent versions of Oracle the BATCH_2_6 index might be used for such an operation, and you could drop both BATCH_6 and BATCH_2)
Well, see if any of this helps. -
This is my first post in this forum regarding query tuning, so my sincere apologies in advance if I have:
1) not included sufficient information,
2) included too much information,
3) not posted to the correct forum
I read through Randolf Geist's web page on instructions to post a query tuning request
and attempted to follow it as closely as possible.
I am attempting to figure out where a view I have constructed can be optimized.
It takes approx. 45 seconds to 1 minute to run; I would like to cut that down to 10 seconds if possible.
The view itself is somewhat complex; I will post the actual code if it will help you help me. Please advise.
I was under the impression that posting the code was not necessary, but if it is, let me know and I will post it.
I have been doing SQL development for a few years, but only recently in Oracle.
I have no experience in looking through the following output and being able to tell where I can improve performance,
so this will be a learning experience for me. Thanks in advance for your help - I appreciate it.
Some additional information - my view is based on tables over which I have no control - it is a third-party application
which I do reporting from. I do have the freedom to create indexes on columns within the tables if necessary.
The statement is simply
SELECT * FROM LLU_V_PRODUCTION_DETAIL_03
which is the name of my view.
here's all the information I've been able to retrieve by following Randolf's instructions:
Oracle version is 10.2.0.1.0 - 64bit
Here are optimizer parameters:
NAME TYPE VALUE
user_dump_dest string C:\ORACLE\PRODUCT\10.2.0\ADMIN
\AXIUMPRODUCTION\UDUMP
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 90
optimizer_index_cost_adj integer 20
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
NAME TYPE VALUE
db_block_size integer 8192
NAME TYPE VALUE
cursor_sharing string EXACT
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 10-29-2005 01:36
SYSSTATS_INFO DSTOP 10-29-2005 01:36
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 1298.56584
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
13 rows selected.Here is the output of EXPLAIN PLAN:
PLAN_TABLE_OUTPUT
Plan hash value: 662813077
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 23M| 53G| | 62330 (2)| 00:12:28 |
| 1 | VIEW | LLU_V_PRODUCTION_DETAIL_03 | 23M| 53G| | 62330 (2)| 00:12:28 |
| 2 | UNION-ALL | | | | | | |
|* 3 | HASH JOIN | | 18M| 5062M| | 1525 (10)| 00:00:19 |
| 4 | VIEW | index$_join$_007 | 1725 | 25875 | | 4 (25)| 00:00:01 |
|* 5 | HASH JOIN | | | | | | |
| 6 | INDEX FAST FULL SCAN | USERS_PRIMARY | 1725 | 25875 | | 1 (0)| 00:00:01 |
| 7 | INDEX FAST FULL SCAN | USERS_PRODUCER | 1725 | 25875 | | 2 (0)| 00:00:01 |
|* 8 | HASH JOIN | | 416K| 105M| | 1399 (2)| 00:00:17 |
| 9 | TABLE ACCESS FULL | PRODUCER | 1396 | 118K| | 24 (0)| 00:00:01 |
|* 10 | HASH JOIN | | 29819 | 5183K| | 1372 (2)| 00:00:17 |
| 11 | TABLE ACCESS FULL | CLASS | 20 | 1660 | | 3 (0)| 00:00:01 |
|* 12 | TABLE ACCESS FULL | QR_PRODUCTION | 149K| 13M| | 1367 (2)| 00:00:17 |
|* 13 | FILTER | | | | | | |
|* 14 | HASH JOIN | | 16M| 5651M| | 32983 (2)| 00:06:36 |
| 15 | VIEW | index$_join$_014 | 1725 | 25875 | | 4 (25)| 00:00:01 |
|* 16 | HASH JOIN | | | | | | |
| 17 | INDEX FAST FULL SCAN | USERS_PRIMARY | 1725 | 25875 | | 1 (0)| 00:00:01 |
| 18 | INDEX FAST FULL SCAN | USERS_PRODUCER | 1725 | 25875 | | 2 (0)| 00:00:01 |
|* 19 | HASH JOIN | | 149K| 49M| | 32874 (1)| 00:06:35 |
| 20 | TABLE ACCESS FULL | CLASS | 20 | 1660 | | 3 (0)| 00:00:01 |
|* 21 | HASH JOIN | | 149K| 37M| | 32870 (1)| 00:06:35 |
| 22 | TABLE ACCESS FULL | PRODUCER | 1396 | 118K| | 24 (0)| 00:00:01 |
|* 23 | HASH JOIN | | 222K| 37M| 12M| 32844 (1)| 00:06:35 |
| 24 | TABLE ACCESS FULL | PATIENT | 188K| 10M| | 6979 (1)| 00:01:24 |
|* 25 | HASH JOIN | | 222K| 24M| | 23860 (2)| 00:04:47 |
|* 26 | TABLE ACCESS FULL | PROCEDUR | 888 | 44400 | | 11 (0)| 00:00:01 |
|* 27 | TABLE ACCESS FULL | TRX | 442K| 28M| | 23845 (2)| 00:04:47 |
|* 28 | TABLE ACCESS FULL | USERS | 1 | 11 | | 55 (0)| 00:00:01 |
| 29 | NESTED LOOPS | | 1 | 473 | | 25798 (1)| 00:05:10 |
| 30 | NESTED LOOPS | | 1 | 413 | | 25797 (1)| 00:05:10 |
| 31 | NESTED LOOPS | | 1 | 398 | | 25796 (1)| 00:05:10 |
| 32 | NESTED LOOPS | | 1 | 390 | | 25795 (1)| 00:05:10 |
|* 33 | HASH JOIN | | 1 | 303 | | 25794 (1)| 00:05:10 |
| 34 | TABLE ACCESS FULL | LLU_EVALUATION_DESCRIPTIONS | 95 | 6175 | | 3 (0)| 00:00:01 |
|* 35 | HASH JOIN | | 4630 | 1076K| | 25791 (1)| 00:05:10 |
|* 36 | HASH JOIN | | 9607 | 1623K| | 23834 (1)| 00:04:47 |
| 37 | MERGE JOIN | | 888 | 91464 | | 13 (8)| 00:00:01 |
| 38 | TABLE ACCESS BY INDEX ROWID | CLASS | 20 | 1660 | | 1 (0)| 00:00:01 |
| 39 | INDEX FULL SCAN | CLASS_PRIMARY | 20 | | | 1 (0)| 00:00:01 |
|* 40 | SORT JOIN | | 888 | 17760 | | 12 (9)| 00:00:01 |
|* 41 | TABLE ACCESS FULL | PROCEDUR | 888 | 17760 | | 11 (0)| 00:00:01 |
|* 42 | TABLE ACCESS FULL | TRX | 19125 | 1307K| | 23820 (1)| 00:04:46 |
|* 43 | TABLE ACCESS FULL | GRADITEM | 655K| 40M| | 1952 (1)| 00:00:24 |
| 44 | TABLE ACCESS BY INDEX ROWID | PRODUCER | 1 | 87 | | 1 (0)| 00:00:01 |
|* 45 | INDEX UNIQUE SCAN | PRODUCER_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 46 | TABLE ACCESS BY INDEX ROWID | GRADING | 1 | 8 | | 1 (0)| 00:00:01 |
|* 47 | INDEX UNIQUE SCAN | GRADING_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 48 | TABLE ACCESS BY INDEX ROWID | USERS | 221 | 3315 | | 1 (0)| 00:00:01 |
|* 49 | INDEX RANGE SCAN | USERS_PRODUCER | 1 | | | 1 (0)| 00:00:01 |
| 50 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 60 | | 1 (0)| 00:00:01 |
|* 51 | INDEX UNIQUE SCAN | PATIENT_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 52 | TABLE ACCESS BY INDEX ROWID | USERS | 109 | 1635 | | 1 (0)| 00:00:01 |
| 53 | NESTED LOOPS | | 1 | 438 | | 2023 (1)| 00:00:25 |
| 54 | NESTED LOOPS | | 1 | 423 | | 2022 (1)| 00:00:25 |
| 55 | NESTED LOOPS | | 1 | 363 | | 2021 (1)| 00:00:25 |
| 56 | NESTED LOOPS | | 1 | 276 | | 2020 (1)| 00:00:25 |
| 57 | NESTED LOOPS | | 1 | 193 | | 2019 (1)| 00:00:25 |
| 58 | NESTED LOOPS | | 1 | 185 | | 2018 (1)| 00:00:25 |
| 59 | NESTED LOOPS | | 1 | 173 | | 2017 (1)| 00:00:25 |
| 60 | NESTED LOOPS | | 1 | 140 | | 2016 (1)| 00:00:25 |
|* 61 | TABLE ACCESS FULL | GRADITEM | 317 | 23141 | | 1953 (2)| 00:00:24 |
|* 62 | TABLE ACCESS BY INDEX ROWID| TRX | 1 | 67 | | 1 (0)| 00:00:01 |
|* 63 | INDEX UNIQUE SCAN | TRX_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 64 | TABLE ACCESS BY INDEX ROWID | TRX | 1 | 33 | | 1 (0)| 00:00:01 |
|* 65 | INDEX UNIQUE SCAN | TRX_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 66 | TABLE ACCESS BY INDEX ROWID | GRADITEM | 1 | 12 | | 1 (0)| 00:00:01 |
|* 67 | INDEX RANGE SCAN | GRADITEM_ID | 19 | | | 1 (0)| 00:00:01 |
|* 68 | TABLE ACCESS BY INDEX ROWID | GRADING | 1 | 8 | | 1 (0)| 00:00:01 |
|* 69 | INDEX UNIQUE SCAN | GRADING_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 70 | TABLE ACCESS BY INDEX ROWID | CLASS | 1 | 83 | | 1 (0)| 00:00:01 |
|* 71 | INDEX UNIQUE SCAN | CLASS_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 72 | TABLE ACCESS BY INDEX ROWID | PRODUCER | 1 | 87 | | 1 (0)| 00:00:01 |
|* 73 | INDEX UNIQUE SCAN | PRODUCER_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
| 74 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 60 | | 1 (0)| 00:00:01 |
|* 75 | INDEX UNIQUE SCAN | PATIENT_PRIMARY | 1 | | | 1 (0)| 00:00:01 |
|* 76 | INDEX RANGE SCAN | USERS_PRODUCER | 1 | | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("QRP"."ProviderID"="U1"."Producer")
5 - access(ROWID=ROWID)
8 - access(TRIM("QRP"."ProviderID")=TRIM("P"."Producer"))
10 - access(TRIM("QRP"."axiUm_Discipline")=TRIM("CLASS"."Class"))
12 - filter("QRP"."ProviderID" IS NOT NULL AND "QRP"."Location"<'9990' AND "QRP"."ProcedureID"<>185 AND
"QRP"."PatientFirstName"<>'NON-PATIENT' AND ("QRP"."PatientFirstName"<>'TED' OR "QRP"."PatientLastName" NOT LIKE
'CAVENDER%'))
13 - filter( NOT EXISTS (SELECT 0 FROM AXIUM."USERS" "USERS" WHERE "Custom3"='YES' AND LNNVL("User"<>:B1)) OR
TO_CHAR(INTERNAL_FUNCTION("P"."EndDate"),'YYYY')<'2011' OR TRIM(TO_CHAR(INTERNAL_FUNCTION("P"."EndDate"),'YYYY')) IS
NULL OR "TRX"."Procedure"='A0021' OR "TRX"."Procedure"='A0022')
14 - access("TRX"."Producer"="U1"."Producer")
16 - access(ROWID=ROWID)
19 - access("PROC"."Discipline"="CLASS"."Class")
21 - access("TRX"."Producer"="P"."Producer")
23 - access("TRX"."Patient"="PAT"."Patient")
25 - access("TRX"."Procedure"="PROC"."Procedure")
26 - filter("PROC"."Discipline" IS NOT NULL)
27 - filter("TRX"."Deleted"=0 AND "TRX"."Status"='C' AND "TRX"."Procedure" NOT LIKE 'D0149%' AND
"TRX"."Procedure"<>'D5001C')
28 - filter("Custom3"='YES' AND LNNVL("User"<>:B1))
33 - access(TRIM(UPPER("GI"."QuestionText"))=TRIM(UPPER("LLU"."GRADITEM_QuestionText")) AND
TRIM(UPPER("GI"."Text"))=TRIM(UPPER("LLU"."GRADITEM_Text")) AND TRIM("TRX"."Procedure")=TRIM("LLU"."ProcedureCode"))
35 - access("TRX"."Type"="GI"."Type" AND "TRX"."Id"="GI"."Id" AND "TRX"."Treatment"="GI"."Treatment")
36 - access("TRX"."Procedure"="PROC"."Procedure")
40 - access("PROC"."Discipline"="CLASS"."Class")
filter("PROC"."Discipline"="CLASS"."Class")
41 - filter("PROC"."Discipline" IS NOT NULL)
42 - filter("TRX"."Grading"<>0 AND "TRX"."Deleted"=0 AND "TRX"."Status"='C')
43 - filter("GI"."Grading"<>0)
45 - access("TRX"."Producer"="P"."Producer")
46 - filter("G"."Deleted"=0)
47 - access("TRX"."Grading"="G"."Grading")
filter("G"."Grading"<>0 AND "G"."Grading"="GI"."Grading")
49 - access("TRX"."Producer"="U1"."Producer")
51 - access("TRX"."Patient"="PAT"."Patient")
61 - filter("GI"."IsHeading"=3 AND TRIM("GI"."QuestionText")='Comments' AND "GI"."Grading"<>0)
62 - filter("TRX"."Grading"<>0 AND "TRX"."Deleted"=0 AND "TRX"."Status"='C' AND ("TRX"."Procedure"='G1002' OR
"TRX"."Procedure"='G1003'))
63 - access("GI"."Type"="TRX"."Type" AND "GI"."Id"="TRX"."Id" AND "GI"."Treatment"="TRX"."Treatment")
64 - filter("TRX"."Grading"<>0 AND "TRX"."Deleted"=0 AND "TRX"."Status"='C' AND ("TRX"."Procedure"='G1002' OR
"TRX"."Procedure"='G1003') AND "TRX"."Grading"="TRX"."Grading")
65 - access("TRX"."Type"="TRX"."Type" AND "TRX"."Id"="TRX"."Id" AND "TRX"."Treatment"="TRX"."Treatment")
66 - filter("GI"."RelValue"<>0 AND "TRX"."Type"="GI"."Type" AND "TRX"."Treatment"="GI"."Treatment")
67 - access("TRX"."Id"="GI"."Id")
68 - filter("G"."Deleted"=0)
69 - access("TRX"."Grading"="G"."Grading")
filter("G"."Grading"<>0 AND "GI"."Grading"="G"."Grading")
71 - access("TRX"."Discipline"="CLASS"."Class")
73 - access("TRX"."Producer"="P"."Producer")
75 - access("TRX"."Patient"="PAT"."Patient")
76 - access("TRX"."Producer"="U1"."Producer")
138 rows selected.
Elapsed: 00:00:00.62
631015 rows selected.
Elapsed: 00:01:49.13Output from AUTOTRACE (I think)
NOTE: this post was too long for the forum, so I have removed a number of lines in the following output which appeared to be duplicating the above section (EXPLAIN PLAN).
Statistics
2657 recursive calls
0 db block gets
12734113 consistent gets
13499 physical reads
0 redo size
103697740 bytes sent via SQL*Net to client
69744 bytes received via SQL*Net from client
6312 SQL*Net roundtrips to/from client
76 sorts (memory)
0 sorts (disk)
631015 rows processedThe TKPROF output
select * from llu_v_production_detail_03
call count cpu elapsed disk query current rows
Parse 1 0.51 0.51 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 6312 88.09 98.01 13490 12733584 0 631015
total 6314 88.60 98.52 13490 12733584 0 631015
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 57
Rows Row Source Operation
631015 VIEW LLU_V_PRODUCTION_DETAIL_03 (cr=12733584 pr=13490 pw=0 time=92145592 us)
631015 UNION-ALL (cr=12733584 pr=13490 pw=0 time=91514573 us)
125485 HASH JOIN (cr=8099 pr=6396 pw=0 time=1523326 us)
1725 VIEW index$_join$_007 (cr=24 pr=0 pw=0 time=4777 us)
1725 HASH JOIN (cr=24 pr=0 pw=0 time=3051 us)
1725 INDEX FAST FULL SCAN USERS_PRIMARY (cr=7 pr=0 pw=0 time=50 us)(object id 55023)
1725 INDEX FAST FULL SCAN USERS_PRODUCER (cr=17 pr=0 pw=0 time=16 us)(object id 55024)
144513 HASH JOIN (cr=8075 pr=6396 pw=0 time=2326445 us)
1396 TABLE ACCESS FULL PRODUCER (cr=107 pr=0 pw=0 time=29 us)
144513 HASH JOIN (cr=7968 pr=6396 pw=0 time=2035684 us)
20 TABLE ACCESS FULL CLASS (cr=7 pr=0 pw=0 time=71 us)
151043 TABLE ACCESS FULL QR_PRODUCTION (cr=7961 pr=6396 pw=0 time=313553 us)
462685 FILTER (cr=10755862 pr=7094 pw=0 time=58570941 us)
466790 HASH JOIN (cr=145247 pr=7094 pw=0 time=11007301 us)
1725 VIEW index$_join$_014 (cr=24 pr=0 pw=0 time=6817 us)
1725 HASH JOIN (cr=24 pr=0 pw=0 time=5091 us)
1725 INDEX FAST FULL SCAN USERS_PRIMARY (cr=7 pr=0 pw=0 time=35 us)(object id 55023)
1725 INDEX FAST FULL SCAN USERS_PRODUCER (cr=17 pr=0 pw=0 time=19 us)(object id 55024)
485205 HASH JOIN (cr=145223 pr=7094 pw=0 time=10945107 us)
20 TABLE ACCESS FULL CLASS (cr=7 pr=0 pw=0 time=105 us)
507772 HASH JOIN (cr=145216 pr=7094 pw=0 time=11947534 us)
1396 TABLE ACCESS FULL PRODUCER (cr=107 pr=0 pw=0 time=18 us)
507772 HASH JOIN (cr=145109 pr=7094 pw=0 time=10924473 us)
188967 TABLE ACCESS FULL PATIENT (cr=31792 pr=0 pw=0 time=188998 us)
507772 HASH JOIN (cr=113317 pr=7094 pw=0 time=9652037 us)
895 TABLE ACCESS FULL PROCEDUR (cr=46 pr=0 pw=0 time=65 us)
509321 TABLE ACCESS FULL TRX (cr=113271 pr=7094 pw=0 time=5604567 us)
8548 TABLE ACCESS FULL USERS (cr=10610615 pr=0 pw=0 time=39053120 us)
42669 NESTED LOOPS (cr=507317 pr=0 pw=0 time=3686506 us)
42669 NESTED LOOPS (cr=421535 pr=0 pw=0 time=3217140 us)
45269 NESTED LOOPS (cr=301155 pr=0 pw=0 time=2449542 us)
45323 NESTED LOOPS (cr=210131 pr=0 pw=0 time=2134056 us)
45323 HASH JOIN (cr=119056 pr=0 pw=0 time=1635472 us)
95 TABLE ACCESS FULL LLU_EVALUATION_DESCRIPTIONS (cr=7 pr=0 pw=0 time=118 us)
98272 HASH JOIN (cr=119049 pr=0 pw=0 time=1446703 us)
46996 HASH JOIN (cr=109018 pr=0 pw=0 time=944857 us)
786 MERGE JOIN (cr=50 pr=0 pw=0 time=1528 us)
20 TABLE ACCESS BY INDEX ROWID CLASS (cr=4 pr=0 pw=0 time=99 us)
20 INDEX FULL SCAN CLASS_PRIMARY (cr=1 pr=0 pw=0 time=10 us)(object id 53850)
786 SORT JOIN (cr=46 pr=0 pw=0 time=750 us)
895 TABLE ACCESS FULL PROCEDUR (cr=46 pr=0 pw=0 time=18 us)
47196 TABLE ACCESS FULL TRX (cr=108968 pr=0 pw=0 time=805137 us)
696300 TABLE ACCESS FULL GRADITEM (cr=10031 pr=0 pw=0 time=277 us)
45323 TABLE ACCESS BY INDEX ROWID PRODUCER (cr=91075 pr=0 pw=0 time=414937 us)
45323 INDEX UNIQUE SCAN PRODUCER_PRIMARY (cr=45752 pr=0 pw=0 time=198709 us)(object id 54581)
45269 TABLE ACCESS BY INDEX ROWID GRADING (cr=91024 pr=0 pw=0 time=353081 us)
45270 INDEX UNIQUE SCAN GRADING_PRIMARY (cr=45753 pr=0 pw=0 time=173185 us)(object id 54088)
42669 TABLE ACCESS BY INDEX ROWID USERS (cr=120380 pr=0 pw=0 time=703786 us)
42669 INDEX RANGE SCAN USERS_PRODUCER (cr=46127 pr=0 pw=0 time=249186 us)(object id 55024)
42669 TABLE ACCESS BY INDEX ROWID PATIENT (cr=85782 pr=0 pw=0 time=407452 us)
42669 INDEX UNIQUE SCAN PATIENT_PRIMARY (cr=43098 pr=0 pw=0 time=198477 us)(object id 54370)
176 TABLE ACCESS BY INDEX ROWID USERS (cr=49426 pr=0 pw=0 time=1783886 us)
367 NESTED LOOPS (cr=49149 pr=0 pw=0 time=6159428 us)
190 NESTED LOOPS (cr=48953 pr=0 pw=0 time=409391 us)
190 NESTED LOOPS (cr=48569 pr=0 pw=0 time=407105 us)
190 NESTED LOOPS (cr=48185 pr=0 pw=0 time=404820 us)
191 NESTED LOOPS (cr=47991 pr=0 pw=0 time=410291 us)
193 NESTED LOOPS (cr=47603 pr=0 pw=0 time=422507 us)
193 NESTED LOOPS (cr=46979 pr=0 pw=0 time=416890 us)
193 NESTED LOOPS (cr=46396 pr=0 pw=0 time=414374 us)
14285 TABLE ACCESS FULL GRADITEM (cr=9602 pr=0 pw=0 time=85793 us)
193 TABLE ACCESS BY INDEX ROWID TRX (cr=36794 pr=0 pw=0 time=128427 us)
8218 INDEX UNIQUE SCAN TRX_PRIMARY (cr=28576 pr=0 pw=0 time=64353 us)(object id 54930)
193 TABLE ACCESS BY INDEX ROWID TRX (cr=583 pr=0 pw=0 time=2169 us)
193 INDEX UNIQUE SCAN TRX_PRIMARY (cr=390 pr=0 pw=0 time=918 us)(object id 54930)
193 TABLE ACCESS BY INDEX ROWID GRADITEM (cr=624 pr=0 pw=0 time=4840 us)
1547 INDEX RANGE SCAN GRADITEM_ID (cr=395 pr=0 pw=0 time=2910 us)(object id 54093)
191 TABLE ACCESS BY INDEX ROWID GRADING (cr=388 pr=0 pw=0 time=1887 us)
191 INDEX UNIQUE SCAN GRADING_PRIMARY (cr=197 pr=0 pw=0 time=943 us)(object id 54088)
190 TABLE ACCESS BY INDEX ROWID CLASS (cr=194 pr=0 pw=0 time=1306 us)
190 INDEX UNIQUE SCAN CLASS_PRIMARY (cr=4 pr=0 pw=0 time=551 us)(object id 53850)
190 TABLE ACCESS BY INDEX ROWID PRODUCER (cr=384 pr=0 pw=0 time=1617 us)
190 INDEX UNIQUE SCAN PRODUCER_PRIMARY (cr=194 pr=0 pw=0 time=715 us)(object id 54581)
190 TABLE ACCESS BY INDEX ROWID PATIENT (cr=384 pr=0 pw=0 time=1941 us)
190 INDEX UNIQUE SCAN PATIENT_PRIMARY (cr=194 pr=0 pw=0 time=939 us)(object id 54370)
176 INDEX RANGE SCAN USERS_PRODUCER (cr=196 pr=0 pw=0 time=1389 us)(object id 55024)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 6312 0.00 0.00
db file scattered read 1614 0.02 2.08
SQL*Net message from client 6312 0.00 10.11
SQL*Net more data to client 48662 0.00 0.70
db file sequential read 4645 0.02 7.11
latch: shared pool 7 0.00 0.00
latch: cache buffers chains 1 0.00 0.00
********************************************************************************Again, I apologize if this is way more information than is necessary.
All advice/suggestions/assistance will be gratefully accepted.
CarlHi Rob,
Thank you for replying. Here is the view definition . . . it looks pretty convoluted, I know.
I am reporting from a database which I have no control over other than to add indexes where needed.
For reporting purposes, I am needing to create the dataset from a number of different tables; hence all the UNION clauses.
-- CODE FOLLOWS
CREATE OR REPLACE VIEW LLU_V_PRODUCTION_DETAIL_03
AS
SELECT
'QR' AS "Source",
U1."User" AS "UserID",
QRP."ProviderID" AS "ProviderID",
P."LastName" AS "ProviderLastName",
P."FirstName" AS "ProviderFirstName",
TO_CHAR(P."EndDate",'YYYY') AS "GraduationYear",
P."PGroup",
QRP."PatientID",
QRP."ChartNumber",
QRP."PatientLastName",
QRP."PatientFirstName",
QRP."ProcedureID" || '-' || QRP."ProcedureSuffix" AS "Procedure",
QRP."ProcedureDescription",
QRP."Tooth" AS "Site",
QRP."Surface",
QRP."axiUm_Discipline" AS "Discipline",
"CLASS"."Rank" AS "DisciplineSorter",
"CLASS"."Name" AS "DisciplineName",
QRP."Points",
0 AS "Hours",
QRP."ServiceDate",
0 AS "Id",
QRP."UniqueID" AS "Grading",
0 AS "LastSort",
QRP."CategoryID",
'' AS "CPAR comments"
FROM QR_PRODUCTION QRP
INNER JOIN PRODUCER P
ON TRIM(QRP."ProviderID") = TRIM(P."Producer")
INNER JOIN CLASS
ON TRIM(QRP."axiUm_Discipline") = TRIM(CLASS."Class")
INNER JOIN USERS U1
ON QRP."ProviderID" = U1."Producer"
WHERE (QRP."Location" < '9990')
AND (QRP."ProviderID" IS NOT NULL)
AND (QRP."ProcedureID" <> 185)
-- skip the Cavender family - training patients
AND NOT (QRP."PatientLastName" LIKE 'CAVENDER%' AND QRP."PatientFirstName" = 'TED')
AND QRP."PatientFirstName" <> 'NON-PATIENT'
--ORDER BY QRP."ProcedureID"
UNION ALL
SELECT
'axiUm TRX' AS "Source",
U1."User" AS "UserID",
TRX."Producer" AS "ProviderID",
P."LastName",
P."FirstName",
TO_CHAR(P."EndDate",'YYYY') AS "GraduationYear",
P."PGroup",
PAT."Patient",
PAT."Chart",
PAT."Last" AS "PatientLastName",
PAT."First" AS "PatientFirstName",
TRX."Procedure",
PROC."Description",
TRX."Site",
TRX."Surface",
TRIM(PROC."Discipline") AS "Discipline",
"CLASS"."Rank" AS "DisciplineSorter",
"CLASS"."Name",
CASE WHEN
((TRX."Procedure" IN ('A0013','A0019','A0020','A0021','A0023','A0024','A0025','A0026','A0027','A0028','A0029','A0030','O179'))
OR
-- no points are to be awarded for any procedures performed on typodonts
(EXISTS (SELECT 1 FROM PTTYPES PTT WHERE PTT."Patient" = PAT."Patient" and PTT."PatType" = 'TYPO' and PTT."Deleted" = 0)))
AND -- except for the following procedures
(TRX."Procedure" NOT IN ('A0015','A0016','A0018','D0210'))
THEN 0 ELSE PROC."RelValue" END AS "Points",
CASE WHEN TRX."Procedure" IN ('A0013','A0019','A0020','A0021','A0023','A0024','A0025','A0026','A0027','A0028','A0029','A0030','O179')
THEN PROC."RelValue" ELSE 0 END AS "Hours",
TRX."TreatmentDate",
TRX."Id",
TRX."Grading",
-1 AS "LastSort",
-- additional link conditions added and table name changed on 1 July 2009 - cji
SELECT "CategoryID" FROM LLU_CATEGORIES_X_PROCEDURES_03 LLU
WHERE TRX."Procedure" = LLU."ProcedureID"
AND TO_CHAR(P."EndDate",'YYYY') = LLU."GraduationYear"
AND SUBSTR(TRX."Producer",1,1) = LLU."ProviderType"
AND LLU."CategoryID" NOT IN (82)
) AS "CategoryID",
'' AS "CPAR comments"
FROM TRX
INNER JOIN PATIENT PAT
ON TRX."Patient" = PAT."Patient"
INNER JOIN USERS U1
ON TRX."Producer" = U1."Producer"
INNER JOIN PROCEDUR PROC
ON TRX."Procedure" = PROC."Procedure"
INNER JOIN CLASS
ON PROC."Discipline" = CLASS."Class"
INNER JOIN PRODUCER P
ON TRX."Producer" = P."Producer"
WHERE (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
--AND (TRX."Grading" = 0)
AND (TRX."Procedure" NOT LIKE 'D0149%')
AND (TRX."Procedure" <> 'D5001C')
-- exclude all procedures approved by Peds faculty ONLY FOR CLASS OF 2011 AND LATER
-- EXCEPT FOR the Peds Block code (A0021 and A0022) - always include those
AND NOT
TRX."AppUser" IN (SELECT "User" FROM USERS WHERE "Custom3" = 'YES') -- Peds faculty
AND
TO_CHAR(P."EndDate",'YYYY') >= '2011'
AND
TRIM(TO_CHAR(P."EndDate",'YYYY')) IS NOT NULL
AND
TRX."Procedure" NOT IN ('A0021','A0022')
UNION ALL
SELECT
'axiUm GRADING' AS "Source",
U1."User" AS "UserID",
TRX."Producer" AS "ProviderID",
P."LastName",
P."FirstName",
TO_CHAR(P."EndDate",'YYYY'), -- Graduation year
P."PGroup",
PAT."Patient",
PAT."Chart",
PAT."Last" AS "PatientLastName",
PAT."First" AS "PatientFirstName",
TRX."Procedure",
LLU."Description",
TRX."Site",
TRX."Surface",
TRIM(PROC."Discipline") AS "Discipline",
"CLASS"."Rank" AS "DisciplineSorter",
"CLASS"."Name",
LLU."Points", --LLU_POINTS_FROM_EVALUATIONS(TRX."Procedure", nvl(GI."Text",0)),
0 AS "Hours",
TRX."TreatmentDate",
GI."Id",
GI."Grading",
GI."Row" AS "LastSort",
LLU."CategoryID",
'' AS "CPAR comments"
FROM TRX
INNER JOIN PATIENT PAT
ON TRX."Patient" = PAT."Patient"
INNER JOIN PRODUCER P
ON TRX."Producer" = P."Producer"
INNER JOIN GRADING G
ON TRX."Grading" = G."Grading"
INNER JOIN GRADITEM GI
ON G."Grading" = GI."Grading"
AND TRX."Type" = GI."Type"
AND TRX."Id" = GI."Id"
AND TRX."Treatment" = GI."Treatment"
INNER JOIN PROCEDUR PROC
ON TRX."Procedure" = PROC."Procedure"
INNER JOIN CLASS
ON PROC."Discipline" = CLASS."Class"
INNER JOIN LLU_EVALUATION_DESCRIPTIONS LLU
ON (TRIM(UPPER(GI."QuestionText")) = TRIM(UPPER(LLU."GRADITEM_QuestionText")))
AND (TRIM(UPPER(GI."Text")) = TRIM(UPPER(LLU."GRADITEM_Text")))
AND (TRIM(TRX."Procedure") = TRIM(LLU."ProcedureCode"))
INNER JOIN USERS U1
ON TRX."Producer" = U1."Producer"
WHERE (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
AND (TRX."Grading" <> 0)
AND (G."Deleted" = 0)
UNION ALL
SELECT 'ClinPtsAdj',
U1."User" AS "UserID",
TRX."Producer",
P."LastName", P."FirstName",
TO_CHAR(P."EndDate",'YYYY'), -- Graduation year
P."PGroup", PAT."Patient", PAT."Chart", PAT."Last", PAT."First",
TRX."Procedure",
'Clinic points adjustment',
'' AS "Site",
'' AS "Surface",
TRIM(TRX."Discipline"),
"CLASS"."Rank",
"CLASS"."Name",
DERIVED."Points",
0 AS "Hours",
GI."Date",
GI."Id",
GI."Grading",
GI."Row",
NULL AS "CategoryID",
TRIM(REPLACE(GI."Note", CHR(13) || CHR(10), ' '))
FROM TRX
INNER JOIN PATIENT PAT
ON (TRX."Patient" = PAT."Patient")
INNER JOIN PRODUCER P
ON (TRX."Producer" = P."Producer")
INNER JOIN CLASS
ON (TRX."Discipline" = CLASS."Class")
INNER JOIN GRADING G
ON (TRX."Grading" = G."Grading")
INNER JOIN GRADITEM GI
ON (GI."Grading" = G."Grading")
AND (GI."Type" = TRX."Type")
AND (GI."Id" = TRX."Id")
AND (GI."Treatment" = TRX."Treatment")
INNER JOIN USERS U1
ON TRX."Producer" = U1."Producer"
INNER JOIN
SELECT TRX."Type", TRX."Id", TRX."Treatment", TRX."Grading",
CASE WHEN TRX."Procedure" = 'G1003' THEN GI."RelValue" * -1 ELSE "RelValue" END AS "Points"
FROM TRX, GRADITEM GI
WHERE (TRX."Type" = GI."Type")
AND (TRX."Id" = GI."Id")
AND (TRX."Treatment" = GI."Treatment")
AND (TRX."Procedure" IN ('G1002','G1003'))
AND (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
AND (TRX."Grading" <> 0)
AND (GI."RelValue" <> 0)
) DERIVED
ON (TRX."Type" = DERIVED."Type")
AND (TRX."Id" = DERIVED."Id")
AND (TRX."Treatment" = DERIVED."Treatment")
AND (TRX."Grading" = DERIVED."Grading")
WHERE (TRX."Status" = 'C')
AND (TRX."Deleted" = 0)
AND (TRX."Grading" <> 0)
AND (G."Deleted" = 0)
AND (TRX."Procedure" IN ('G1002','G1003'))
AND (GI."IsHeading" = 3)
AND (TRIM(GI."QuestionText") = 'Comments')
--ORDER BY "ProviderID", "DisciplineSorter", "Id", "Grading", "Site", "LastSort";A couple of additional points:
The table USERS already had an index on column "Producer"; I added an index on column "Custom3" but it did not seem to make any difference.
Table USERS has 1,725 rows
Table PRODUCER (aliased as P) has 1,396 rows
Table TRX has 1,443,764 rows.
Any additional information you need I will be glad to provide.
Thanks a bunch; it may not be too late to teach an old dog new tricks.
And thank you all for the kind words about the posting; about the only thing I can do well is follow directions.
Carl -
Text index for UNION queries.
Hi All,
Can anyone please help me in tuning search query mentioned below
select id from usr1.organizations where lower(ID_official_name) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_NORM_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NORM_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_dba_name) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_NORM_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fka_name) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_NORM_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_TRANS_NAME) like 'technology%'Here organizations table is the parent table having primary key on id column, and rest all tables are children tables having foreign key on id column referencing to primary key id column in organizations table.
Planning to implement multiple column(Userdatastore) text index on dummy column appended to organizations table. And write triggers on other child tables to trigger the sync for Text index.
But not sure whether we can rewrite this above sql query by replacing union into joins, not sure why developer has not done so.
Can anyone please help me in creating text index for this sql. I do not want to approach cartesian joins as these are having parent-child relationship.
Oracle Version: 10.2.0.4
Please let me know if you need more information1 .As text index is created in parent table on id column, can we somehow search only from particular columns(Parent or child) by using user_datastore and tags for sectioning it?
Below are the sql which i need to make use of text index
select m.id from id_ALIAS_NAMEs an
join organizations m on(m.id=an.id)
where lower(ID_ALIAS_NAME) like 'technology%' and m.id_data_provider<100;
select M.id,ID_ALIAS_NAME,'ID_ALIAS_NAME' AS NAMETYPE
from id_alias_names an JOIN organizations m ON m.id=an.id
where id_data_provider<100 AND coalesce(m.ID_COUNTRY_OF_DOMICILE,m.ID_COUNTRY_OF_INCORPORATION)='US'
AND LOWER(ID_ALIAS_NAME) like LOWER('TECHNOLOGY%')
and F_GetFirstWord(ORG_ALIAS_NAME)='TECHNOLOGY'
The text index must be created on a text column, not a numeric id column. It is common to create it on a dummy column. You can name that column anything you like instead of dummy, like search_columns or some such thing. You can add tags in your procedure, so that your resulting virtual column is like xml data. You can then create a section group, so that you can search within each of those tags. In the example below, I used ctxsys.auto_section_group because it is the simplest to create, but you may get better performance by using another type of section group and naming each individual tag.
SCOTT@orcl_11gR2> -- tables you already have:
SCOTT@orcl_11gR2> create table organizations
2 (id number primary key,
3 id_official_name varchar2 (10),
4 id_official_norm_name varchar2 (10),
5 id_official_eng_name varchar2 (10),
6 id_official_trans_name varchar2 (10),
7 id_data_provider number,
8 id_country_of_domicile varchar2 (10),
9 id_country_of_incorporation varchar2 (10))
10 /
Table created.
SCOTT@orcl_11gR2> create table id_alias_names
2 (id number references organizations (id),
3 id_alias_name varchar2 (10),
4 id_alias_norm_name varchar2 (10),
5 id_alias_eng_name varchar2 (10),
6 id_alias_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> create table id_doing_business_as_names
2 (id number references organizations (id),
3 id_dba_name varchar2 (10),
4 id_dba_norm_name varchar2 (10),
5 id_dba_eng_name varchar2 (10),
6 id_dba_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> create table id_fka_names
2 (id number references organizations (id),
3 id_fka_name varchar2 (10),
4 id_fka_norm_name varchar2 (10),
5 id_fka_eng_name varchar2 (10),
6 id_fka_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> -- test data:
SCOTT@orcl_11gR2> insert all
2 into organizations values (1, 'test', 'name2', 'name3', 'name4', 99, 'US', null)
3 into organizations values (2, 'name1', 'name2', 'name3', 'name4', 99, null, 'US')
4 into organizations values (3, 'name1', 'name2', 'name3', 'name4', 99, null, null)
5 into organizations values (4, 'name1', 'name2', 'name3', 'name4', 101, 'US', 'US')
6 into organizations values (5, 'technology', 'technology', 'technology', 'technology', 99, 'US', 'US')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_alias_names values (1, 'technology', 'name6', 'name7', 'name8')
3 into id_alias_names values (2, 'technology', 'test', 'name7', 'name8')
4 into id_alias_names values (3, 'technology', 'name6', 'name7', 'name8')
5 into id_alias_names values (4, 'technology', 'name6', 'name7', 'name8')
6 into id_alias_names values (5, 'name5', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_doing_business_as_names values (1, 'name9', 'name10', 'name11', 'name12')
3 into id_doing_business_as_names values (2, 'name9', 'name10', 'name11', 'name12')
4 into id_doing_business_as_names values (3, 'name9', 'name10', 'test', 'name12')
5 into id_doing_business_as_names values (4, 'name9', 'name10', 'name11', 'name12')
6 into id_doing_business_as_names values (5, 'technology', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_fka_names values (1, 'name13', 'name14', 'name15', 'name16')
3 into id_fka_names values (2, 'name13', 'name14', 'name15', 'name16')
4 into id_fka_names values (3, 'name13', 'name14', 'name15', 'name16')
5 into id_fka_names values (4, 'name13', 'name14', 'name15', 'test')
6 into id_fka_names values (5, 'technology', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> -- revised procedure to join tables with tags:
SCOTT@orcl_11gR2> create or replace procedure your_proc
2 (p_rowid in rowid,
3 p_clob in out nocopy clob)
4 as
5 begin
6 for r1 in
7 (select id,
8 '<id_official_name>'
9 || id_official_name
10 || '</id_official_name><id_official_norm_name>'
11 || id_official_norm_name
12 || '</id_official_norm_name><id_official_eng_name>'
13 || id_official_eng_name
14 || '</id_official_eng_name><id_official_trans_name>'
15 || id_official_trans_name
16 || '</id_official_trans_name>' as tags_and_values
17 from organizations
18 where rowid = p_rowid)
19 loop
20 dbms_lob.writeappend
21 (p_clob, length (r1.tags_and_values), r1.tags_and_values);
22 for r2 in
23 (select '<id_alias_name>'
24 || id_alias_name
25 || '</id_alias_name><id_alias_norm_name>'
26 || id_alias_norm_name
27 || '</id_alias_norm_name><id_alias_eng_name>'
28 || id_alias_eng_name
29 || '</id_alias_eng_name><id_alias_trans_name>'
30 || id_alias_trans_name
31 || '</id_alias_trans_name>' as tags_and_values
32 from id_alias_names
33 where id = r1.id)
34 loop
35 dbms_lob.writeappend
36 (p_clob, length (r2.tags_and_values), r2.tags_and_values);
37 end loop;
38 for r3 in
39 (select '<id_dba_name>'
40 || id_dba_name
41 || '</id_dba_name><id_dba_norm_name>'
42 || id_dba_norm_name
43 || '</id_dba_norm_name><id_dba_eng_name>'
44 || id_dba_eng_name
45 || '</id_dba_eng_name><id_dba_trans_name>'
46 || id_dba_trans_name
47 || '</id_dba_trans_name>' as tags_and_values
48 from id_doing_business_as_names
49 where id = r1.id)
50 loop
51 dbms_lob.writeappend
52 (p_clob, length (r3.tags_and_values), r3.tags_and_values);
53 end loop;
54 for r4 in
55 (select '<id_fka_name>'
56 || id_fka_name
57 || '</id_fka_name><id_fka_norm_name>'
58 || id_fka_norm_name
59 || '</id_fka_norm_name><id_fka_eng_name>'
60 || id_fka_eng_name
61 || '</id_fka_eng_name><id_fka_trans_name>'
62 || id_fka_trans_name
63 || '</id_fka_trans_name>' as tags_and_values
64 from id_fka_names
65 where id = r1.id)
66 loop
67 dbms_lob.writeappend
68 (p_clob, length (r4.tags_and_values), r4.tags_and_values);
69 end loop;
70 end loop;
71 end your_proc;
72 /
Procedure created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> -- examples of virtual columns that revised procedure returns:
SCOTT@orcl_11gR2> declare
2 v_clob clob;
3 begin
4 for r in
5 (select rowid, id
6 from organizations)
7 loop
8 dbms_lob.createtemporary (v_clob, true);
9 your_proc (r.rowid, v_clob);
10 dbms_output.put_line (r.id);
11 dbms_output.put_line (v_clob);
12 dbms_lob.freetemporary (v_clob);
13 end loop;
14 end;
15 /
1
<id_official_name>test</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name3
</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><i
d_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
2
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>test</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
3
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>test</id_db
a_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_fk
a_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
4
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_
dba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_
fka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>test</id_fka_trans_name>
5
<id_official_name>technology</id_official_name><id_official_norm_name>technology</id_official_norm_name><id_official_eng
_name>technology</id_official_eng_name><id_official_trans_name>technology</id_official_trans_name><id_alias_name>name5</
id_alias_name><id_alias_norm_name>technology</id_alias_norm_name><id_alias_eng_name>technology</id_alias_eng_name><id_al
ias_trans_name>technology</id_alias_trans_name><id_dba_name>technology</id_dba_name><id_dba_norm_name>technology</id_dba
_norm_name><id_dba_eng_name>technology</id_dba_eng_name><id_dba_trans_name>technology</id_dba_trans_name><id_fka_name>te
chnology</id_fka_name><id_fka_norm_name>technology</id_fka_norm_name><id_fka_eng_name>technology</id_fka_eng_name><id_fk
a_trans_name>technology</id_fka_trans_name>
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- user_datastore:
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference ('your_datastore', 'user_datastore');
3 ctx_ddl.set_attribute ('your_datastore', 'procedure', 'your_proc');
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- dummy column:
SCOTT@orcl_11gR2> alter table organizations add (dummy varchar2(1))
2 /
Table altered.
SCOTT@orcl_11gR2> -- index with auto_section_group,
SCOTT@orcl_11gR2> -- must be on a text column, like dummy, not numeric id column:
SCOTT@orcl_11gR2> create index your_index
2 on organizations (dummy)
3 indextype is ctxsys.context
4 parameters
5 ('datastore your_datastore
6 section group ctxsys.auto_section_group')
7 /
Index created.
SCOTT@orcl_11gR2> -- example queries:
SCOTT@orcl_11gR2> select id
2 from organizations
3 where contains (dummy, 'technology within id_alias_name') > 0
4 and id_data_provider < 100
5 /
ID
1
2
3
3 rows selected.
SCOTT@orcl_11gR2> select m.id, an.id_alias_name, 'ID_ALIAS_NAME' as nametype
2 from id_alias_names an join organizations m on m.id = an.id
3 where contains (m.dummy, 'technology within id_alias_name') > 0
4 and m.id_data_provider < 100
5 and coalesce (m.id_country_of_domicile, m.id_country_of_incorporation) = 'US'
6 /
ID ID_ALIAS_N NAMETYPE
1 technology ID_ALIAS_NAME
2 technology ID_ALIAS_NAME
2 rows selected.
SCOTT@orcl_11gR2> -
InterMedia Text Search results
We have interMedia Text enabled on our 3.0.9.8.2 install and, for Search Results, I need to understand how the percentage score is calculated and, if results have the same score, how the order is determined. Is it possible to reorder the results because it appears to be random? Can anyone point me to the relevant documentation?
So Stephen, if I understand correctly, you have URL items, where the URL references the content in the IFS repository. This means that these items are being indexed by the WWSBR_URL_CTX_INDX. It'd be interesting to see if the results are returned as you would expect them to be using this index alone. This will tell you if there is a problem with Intermedia Text or if the problem lies with the way that Portal is using Intermedia Text and combining the scores from the multiple indexes.
Try running a SQL query like
select i.title, score(10) scr from wwv_things i, wwsbr_url$ u
where i.id=u.object_id
and contains (u.absolute_url,'${oracle}',10) > 0
order by scr desc
This will match your search term against only text which was indexed by the URL index and returns the display name of the corresponding item. Here I've searched for the term 'oracle'; change this to whatever you were using in your testcase. Note also that the $ implies the stem operator which is used by default in Portal.
If this query doesn't return you the scores that you were expecting then the problem is to do with the way that Intermedia Text is indexing your PDF documents. If it does return what you'd expect then we need to look more closely at what Portal is doing with the scores. -
Oracle Text Index on Materialized View
Hello,
I have designed a search engine for an internet application.
We have different tables for our main business objects, the search is based on the content of all these dependent entities (Product, Company etc...)
So I have created a materialized view to embody this aggregation.
Then I have created a Multi column datastore index on top of the snapshot.
The search engine has to be refreshed automatically 3 times a day, and manually anytime.
This is achieved by executing a complete refresh on the view and rebuild the index, programmatically via Toplink (SqlCall).
The MV refresh looks like this :
alter index usr_batiprod.fullTextMulticolIdx rebuild
and the index rebuild:
begin
DBMS_MVIEW.REFRESH('FT_TEST','C');
end;
Everything was fine until now, we have had lots of tuning on the index side, the refresh process was working fine...
We have let the users access the engine since Thursday (the index had been created on the production environment a fews weeks ago) and since yesterday (or maybe before) we have been experiencing data incoherency on the index...
I've tracked down the pb to the Fulltext Search's refresh process (manual and automatic share the same code) that was crashing on the Materialized view refresh :
java.sql.SQLException: ORA-20000: Oracle Text error:
DRG-50610: internal error: drexdsync
DRG-50857: oracle error in drekrtd (lob erase)
ORA-00060: deadlock detected while waiting for resource
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 832
ORA-06512: at line 2
Again, we had tested the functionality thoroughly and never experienced such behaviour before... even while refreshing the materialized view and the index 3 times (or more) a day..
Once I dropped the Oracle Text Index, I was able to refresh the MV again..
so it looks like the index was in some incoherent state and was holding a lock on the materialized view...
Maybe my Index refresh call is wrong, and a stronger load on the functionality leads quickly to this pb, I dont know..
I had always been a bit doubtful towards my index rebuild call, so Im thinking about using a more complete call :
alter index usr_batiprod.fullTextMulticolIdx rebuild parameters ('sync')
is it enough, or do I have to switch to a 'Oracle Text' specific call ?
Is there another possible reason for the MV lock ?
Thank you for your support
Best Regards
Olivier CuzacqMVs are constructed in different ways and have lots of different uses.
Why not just use MV as temp table for OT (Oracle Text) index?
Refresh MV OT_TEMP.
Delete all not matching rows from OT.
Insert all missing missing rows from OT_TEMP to OT.
sync OT index (online).
Query table OT.
Maybe you are looking for
-
Transfer .pages documents to iPad
I'm waiting for the 3G model, but I figure owners of the WiFi only model could help answer my questions... I know the iPad doesn't have a USB port (why Apple, why?!), but I have some .pages files on my mac and duplicate copies on a USB, and if I coul
-
Bootable Backup on Intel Macs?
I read this on the internet. Has anyone checked this out? A Bootable Backup for an Intel Mac Shortly after I got my shiny new 20″ Intel iMac I read in a forum somewhere that booting from an external firewire enclosure was no longer supported on the I
-
Flash not fully functioning in Chrome
When going to a flash page, initial video or flash object will play, but no actions (pause/play/follow link) can be selected. After any click in the flash pane, the mouse pointer will be constantly engaged (i.e. moving the mouse back and forth acros
-
My upgrade date is 1-21-12..My fiance wants to come on a plan with me and her current contract with another company end on Jan 3. Would I be allowed to get my upgrade pricing a little earlier if I am adding a line and changing plans? Also, we are not
-
My Wifi disconnect​s randomly
Can you lend a{please keep your posts courteous}some wifi?