11g R2 で Oracle Text Name Search Facility を使用して適切なパフォーマンスを得る方法を見つけようとしています。
テストのために、オブジェクト ID とフルネームを持つテーブルを作成しました。5,400,000 行:
create table personname as
select p.objectid, p.fname||chr(32)||p.mname||chr(32)||p.lname as fullname
from person p;
次に、データストアとセクション グループの設定を次のように設定します。
begin
begin
ctx_ddl.create_preference('namesearch_ds', 'multi_column_datastore');
ctx_ddl.set_attribute('namesearch_ds', 'columns', 'fullname');
end;
begin
ctx_ddl.create_section_group('namesearch_sg', 'basic_section_group');
ctx_ddl.add_ndata_section('namesearch_sg', 'fullname', 'fullname');
end;
end;
最後にコンテキスト インデックスを作成します。
create index personname_idx
on personname(fullname)
indextype is ctxsys.context
parameters
('datastore namesearch_ds section group namesearch_sg sync(on commit)');
これまでのところ、すべて順調です。ただし、クエリはかなり遅いです。次のような選択を行います。
select score(1), pn.*
from personname pn
where contains(pn.fullname, 'ndata(fullname, Bjørn Egil Hansen)', 1) > 0
and rownum <= 50
order by score(1) desc;
数分かかる場合があり、クエリ内の名前の数に応じて応答時間が長くなるようです。
Oracle doc で提案されているように、さまざまなクエリヒントを使用してみました。
- FIRST_ROWS(50)
- DOMAIN_INDEX_SORT
- パラレル(8)
しかし、大きな違いはないようです (ただし、同じクエリを 2 回実行するとパフォーマンスが大幅に向上するため、測定するのは非常に困難です)。