Oracle提供一个全文索引同步服务进程负责监视索引表变动并且第一时间同步索引。
只需要在后台运行这个进程,它会监视数据的变化,及时进行同步。但由于存在一些问题在未来的ORACLE版本中将要被取代。
host ctxsrv -user ctxsys/ctxsys>&/tmp/ctx.log&
当你启动了CTXSRV服务进程,在后台的同步请求处理就会象事时一样,在你提交修改1,2秒后新的数据马上就被索引了;
默认情况下,如果你不启动CTXSRV进程,索引不会自动更新除非你手工告诉它们去更新自己。使用 alter index <iname> rebuild parameters ('sync') 更新索引。
推荐使用sync同步索引。语法:
ctx_ddl.sync_index(
idx_name IN VARCHAR2 DEFAULT NULL
memory IN VARCHAR2 DEFAULT NULL,
part_name IN VARCHAR2 DEFAULT NULL
parallel_degree IN NUMBER DEFAULT 1);
idx_name 索引名称
memory 指定同步索引需要的内存。默认是系统参数DEFAULT_INDEX_MEMORY 。指定一个大的内存时候可以加快索引效率和查询速度,且索引有较少的碎片
part_name 同步哪个分区索引。
parallel_degree 并行同步索引。设置并行度。
例如:
使用2M内存同步索引myindex
说了这么多我想你是不会使用host ctxsrv -user ctxsys/ctxsys>&/tmp/ctx.log&的
可以TRACE一下看看为什么慢
以下是9I支持的情况;可以尝试先LOAD数据在并行创建索引
QUOTE:
6分区
CONTEXT索引支持在分区表山建立本地分区索引,但仍然有一些限制。如下
分区表必须是按范围分区,不支持HASH分区和复合分区。
你应该为每个分区指定索引分区名称。如果不指定,系统默认为每个分区表指定。分区索引列表的顺序必须和分区表的顺序一致。
可以为每个分区分别指定PRAMETERS参数,但是PARAMETERS只允许包括STORAGE和MEMEROY参数。
不能指定ONLINE建立索引。
可以查询CTX_INDEX_PARTITIONS或者CTX_USER_INDEX_PARTITIONS获得更多信息。
6.1Creating a Local Partitioned Index
PROMPT create partitioned table and populate it
CREATE TABLE part_tab (a int, b varchar2(40)) PARTITION BY RANGE(a)
(partition p_tab1 values less than (10),
partition p_tab2 values less than (20),
partition p_tab3 values less than (30));
PROMPT create customer storage preference assigned each partition
Execute ctx_ddl.drop_preference('mystore1');
Begin
ctx_ddl.create_preference('mystore1', 'BASIC_STORAGE');
ctx_ddl.set_attribute('mystore1', 'I_TABLE_CLAUSE',
'tablespace indx ');
ctx_ddl.set_attribute('mystore1', 'I_INDEX_CLAUSE',
'tablespace users03 compress 2 ');
end;
PROMPT create partitioned index
CREATE INDEX part_idx on part_tab(b) INDEXTYPE IS CTXSYS.CONTEXT
LOCAL (partition p_idx1 parameters(‘storage mystore1’), partition p_idx2 parameters(‘storage mystore2’), partition p_idx3 parameters(‘storage mystore3’));
6.2Creating a Local Partitioned Index in Parallel
可以并行的建立分区索引,加快建立索引速度。但是建立索引不能“一步到位“。我们必须先建立一个unusable索引,然后利DBMS_PCLXUTIL.BUILD_PART_INDEX 并行建立索引。
PROMPT the base table has three partitions.
PROMPT We create a local partitioned unusable index first
create index tdrbip02bx on tdrbip02b(text)
indextype is ctxsys.context local (partition tdrbip02bx1,
partition tdrbip02bx2,
partition tdrbip02bx3)
unusable;
PROMPT run the DBMS_PCLUTIL.BUILD_PART_INDEX, which builds the 3 partitions in parallel (inter-partition parallelism). Also inside each partition, index creation is done in parallel (intra-partition parallelism) with a parallel degree of 2.
begin
dbms_pclxutil.build_part_index(3,2,'TDRBIP02B','TDRBIP02BX',TRUE);
end
/