How to sync and optimize an Oracle Text index?

后端 未结 3 1619
一向
一向 2021-02-04 14:53

We want to use a ctxsys.context index type for full text search. But I was quite surprised, that an index of this type is not automatically updated. We have 3 milli

3条回答
  •  孤城傲影
    2021-02-04 15:37

    I think 'SYNC EVERY' option, as described in previous answer only available in Oracle 10g or newer. If you're using older version of Oracle you would have to run sync operation periodically. For example, you can create following stored procedure:

    CREATE OR REPLACE 
    Procedure sync_ctx_indexes
    IS
     CURSOR sql1 is select distinct(pnd_index_owner||'.'||pnd_index_name) as index_name from ctx_pending;
    BEGIN
     FOR rec1 IN sql1 LOOP
     ctx_ddl.sync_index(rec1.index_name);
     END LOOP;
    END;
    

    and then schedule it run via DBMS_JOB:

    DBMS_JOB.SUBMIT(job_id, 'sync_ctx_indexes;', SYSDATE, 'SYSDATE + 1/720');
    

    As for index optimization, following command can be used (also can be scheduled with DBMS_JOB or via cron):

    alter index my_index rebuild online parameters('optimize full maxtime 60');
    

    There is also CTX_* package with similar function available.

提交回复
热议问题