Using like '%', Oracle performs a full table scan, which consumes a considerable amount of system resources. This allows you to use full-text retrieval of oracle to increase the query speed.
- SQL>Select*FromV $ versionWhereRownum = 1;
- BANNER
- ----------------------------------------------------------------
- OracleDatabase10g Enterprise Edition Release 10.2.0.1.0-Prod
- SQL>Create TableT (textVarchar(4000 ));
- The table has been created.
- SQL>Insert IntoTValues('You love her so much, why don't you leave her');
- One row has been created.
- SQL>BeginCtx_ddl.create_preference ('Club _ lexer','Chinese _ vgram_lexer');End
- 2/
- The PL/SQL process is successfully completed.
- SQL>Create IndexIdx_t_textOnT (text) indextypeIs
- 2 ctxsys. context parameters ('Lexer club_lexer');
- The index has been created.
- SQL>Select Count(*)FromTWhere Contains(Text,'Who')> 0;
- Select Count(*)FromTWhere Contains(Text,'Who')> 0
- *
- Row 3 has an error:
- ORA-29902: An error occurred while executing the ODCIIndexStart () Routine
- ORA-20000: Oracle Text error:
- DRG-10817:CONTAINSA phrase in which a search term contains a disabled word or a disabled word: What
- SQL>Select Count(*)FromTWhere Contains(Text,'Who')> 0;
- COUNT(*)
- ----------
- 1
- SQL>Select Count(*)FromTWhere Contains(Text,'Ta')> 0;
- COUNT(*)
- ----------
- 1
- SQL>Select Count(*)FromTWhere Contains(Text,'Then')> 0;
- COUNT(*)
- ----------
- 1
Regularly synchronize and optimize Indexes
- SQL>Create Or Replace ProcedureHsp_sync_indexAs
- 2Begin
- 3 ctx_ddl.sync_index ('Idx _ t_text');
- 4End;
- 5/
- The process has been created.
- SQL>-- Regularly synchronize Indexes
- SQL> VARIABLE jobno number;
- SQL>BEGIN
- 2 DBMS_JOB.SUBMIT (: jobno,'Children _ sync_index ();',
- 3 SYSDATE,'Sysdate + (1/24/4 )');
- 4Commit;
- 5END;
- 6/
- The PL/SQL process is successfully completed.
- SQL>Create Or Replace ProcedureHsp_optimize_indexAs
- 2Begin
- 3 ctx_ddl.optimize_index ('Idx _ t_text','Full');
- 4End;
- 5/
- The process has been created.
- SQL>-- Regularly optimize Indexes
- SQL> VARIABLE jobno number;
- SQL>BEGIN
- 2 DBMS_JOB.SUBMIT (: jobno,'Heat _ optimize_index ();',
- 3 SYSDATE,'Sysdate + 1');
- 4Commit;
- 5END;
- 6/
- The PL/SQL process is successfully completed.
Before creating a synchronization and optimized storage process, www.bkjia.com should use the sys user to grant permissions to evan users: grant execute on ctx_ddl to evan;
Otherwise, the following message will be reported:
SQL> create or replace procedure hsp_sync_index
2 begin
3 ctx_ddl.sync_index ('idx _ t_text ');
4 end;
5/
Warning: the creation process has a compilation error.
SQL> show errors
PROCEDURE heat _ sync_index error:
LINE/COL ERROR
-------------------------------------------------------------------------
3/5 PL/SQL: Statement ignored
3/5 PLS-00201: The identifier 'ctx _ ddler' must be declared'
In addition, pay special attention to forbidden words.