Fulltext functional lookup on BLOB [message #546073] |
Mon, 05 March 2012 03:54 |
|
munis428
Messages: 1 Registered: March 2012
|
Junior Member |
|
|
Hi,
does Oracle support functional lookup in fulltext index (CONTEXT) on a BLOB column? It works fine on a VARCHAR2 column but I can't get it working on a BLOB.
As an example, assume that there's 'id' column (primary key), fulltext-indexed 'textV' column (varchar2) and fulltext-indexed 'textB' column (blob). If I perform
select * from tbl where id in (1,2) and contains(textV, 'something')>0;
Oracle picks 2 rows by 'id' and then performs functional lookup to see whether these 2 rows match the Oracle Text query. If I do the same on a 'textB' column, Oracle pulls many rows from Oracle Text query and then hash-joins it with rows with ids 1 and 2. Both index and table are quite big (with possibly many matched rows for fulltext search) so this performs much slower than functional lookup.
Using query hints made no difference.
|
|
|
|
Re: Fulltext functional lookup on BLOB [message #546235 is a reply to message #546073] |
Mon, 05 March 2012 21:07 |
|
Barbara Boehmer
Messages: 9100 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
If you upgrade to Oracle 11g, then you can use FILTER BY and SDATA to query both columns with one index hit, similar to the way you would use catsearch with an index set. Please see the demonstration below.
SCOTT@orcl_11gR2> create table tbl
2 (id number primary key,
3 textb blob)
4 /
Table created.
SCOTT@orcl_11gR2> insert all
2 into tbl values (1, utl_raw.cast_to_raw ('something'))
3 into tbl values (2, utl_raw.cast_to_raw ('something'))
4 select * from dual
5 /
2 rows created.
SCOTT@orcl_11gR2> insert into tbl
2 select distinct object_id,
3 utl_raw.cast_to_raw ('something ' || object_name)
4 from user_objects
5 where object_id > 2
6 /
740 rows created.
SCOTT@orcl_11gR2> create index tbl_idx on tbl (textb)
2 indextype is ctxsys.context
3 FILTER BY ID
4 /
Index created.
SCOTT@orcl_11gR2> set autotrace on explain
SCOTT@orcl_11gR2> select id, utl_raw.cast_to_varchar2 (textb)
2 from tbl
3 where contains
4 (textb,
5 'something AND
6 (SDATA (ID = 1) OR
7 SDATA (ID = 2))') > 0
8 /
ID
----------
UTL_RAW.CAST_TO_VARCHAR2(TEXTB)
------------------------------------------------------------------------------------------------------------------------
1
something
2
something
2 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 4198504031
---------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2027 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TBL | 1 | 2027 | 4 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | TBL_IDX | | | 4 (0)| 00:00:01 |
---------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("CTXSYS"."CONTAINS"("TEXTB",'something AND (SDATA (ID
= 1) OR SDATA (ID = 2))')>0)
Note
-----
- dynamic sampling used for this statement (level=2)
SCOTT@orcl_11gR2>
|
|
|
|
|
Re: Fulltext functional lookup on BLOB [message #546387 is a reply to message #546245] |
Tue, 06 March 2012 07:42 |
|
Barbara Boehmer
Messages: 9100 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Michel Cadot wrote on Mon, 05 March 2012 21:12
Does it take care of these tools tags (like the search box of Word, that color, font...)?
Yes, the ctxsys.auto_filter filters out everything but the text of the document, then just indexes the text.
edit: removed the word default as auto_filter is not default but must be specified
[Updated on: Tue, 06 March 2012 08:10] Report message to a moderator
|
|
|
|
|
|