Each time an OracleText full-text index is synchronized, the index becomes more fragmented. The higher the index fragmentation, the worse the search performance becomes. Index fragmentation is unavoidable in a live database where records are actively created, updated and deleted. The rate at which the index fragmentation increases depends on the index synchronization setting and the rate at which records are created, updated or deleted. 

Monitoring the index fragmentation

To obtain statistics about the full-text index execute a script similar to the following:

create table index_stats (ts timestamp, report clob);

declare 
  x clob := null;
begin
  ctx_report.index_stats('aq_fulltext_index', x);
  insert into index_stats (report) values (x);
  dbms_lob.freetemporary(x);
end;

select * from index_stats;

It is recommended to monitor the index fragmentation and determine the maximum index fragmentation where search performance is still acceptable. Based on this, an index maintenance plan can be implemented that will periodically optimize or rebuild the index. A decision must also be made on the tradeoff between index availability and index fragmentation:

Optimizing the full-text index

A fragmented index can be optimized in two ways:

To optimize the index using a the CTX_DDL.OPTIMIZE_INDEX procedure, execute one of the following statements:

-- for heavily fragmented indexes
CALL ctx_ddl.optimize_index('aq_fulltext_index', 'REBUILD')
 
-- for a frequently used token
CALL ctx_ddl.optimize_index('aq_fulltext_index', 'TOKEN', TOKEN=>'example');

Please consult the reference documentation for CTX_DDL.OPTIMIZE_INDEX for details on the various other options available for this stored procedure.

To optimize the index by rebuilding it, the following statement may be executed:

ALTER INDEX aq_fulltext_index REBUILD;

Please consult the reference documentation for OracleText ALTER INDEX REBUILD syntax for various other available options when rebuilding the index.

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels. Note: the article itself also appears as related article, this is a known limitation.