複合語を適切にサポートするために、ドイツ語のテキストを検索するためのカスタム テキスト検索構成を使用しています。
辞書はhttp://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/ (ispell-german-compound.tar.gz) にあります。
辞書は UTF8 に変換され、次のスクリプトを使用して構成をデータベースに追加しました。
DROP TEXT SEARCH DICTIONARY IF EXISTS german_bon_ispell CASCADE;
DROP TEXT SEARCH DICTIONARY IF EXISTS german_bon_stem CASCADE;
CREATE TEXT SEARCH CONFIGURATION german_bon (copy=german);
CREATE TEXT SEARCH DICTIONARY german_bon_stem (
TEMPLATE = snowball,
Language = german,
StopWords = german
);
CREATE TEXT SEARCH DICTIONARY german_bon_ispell (
TEMPLATE = ispell,
dictfile = german,
afffile = german,
StopWords = german
);
ALTER TEXT SEARCH CONFIGURATION german_bon
ALTER MAPPING FOR
asciiword,word,numword,numhword,hword_asciipart,hword_part,hword_numpart
WITH german_bon_ispell, german_bon_stem;
ディクショナリ自体はうまく機能しますが、新しい接続/セッションごとに、この構成を使用した最初のクエリに 1 ~ 2 秒かかります。次の間隔は ~1 ~ 3 ミリ秒です。
この効果は英語の辞書でも観察できますが、それほど劇的ではありません。
db=# \timing
Timing is on.
db=# select ts_debug('english', 'Book');
ts_debug
-----------------------------------------------------------------------
(asciiword,"Word, all ASCII",Book,{english_stem},english_stem,{book})
(1 row)
Time: 6,977 ms
db=# select ts_debug('english', 'Book');
ts_debug
-----------------------------------------------------------------------
(asciiword,"Word, all ASCII",Book,{english_stem},english_stem,{book})
(1 row)
Time: 2,258 ms
db=# select ts_debug('german_bon', 'Buch');
ts_debug
---------------------------------------------------------------------------------------------------
(asciiword,"Word, all ASCII",Buch,"{german_bon_ispell,german_bon_stem}",german_bon_ispell,{buch})
(1 row)
Time: 916,286 ms
db=# select ts_debug('german_bon', 'Buch');
ts_debug
---------------------------------------------------------------------------------------------------
(asciiword,"Word, all ASCII",Buch,"{german_bon_ispell,german_bon_stem}",german_bon_ispell,{buch})
(1 row)
Time: 1,240 ms
db=#
私が現在認識している唯一の回避策は、永続的な接続/接続プーリングの使用であり、そのために pgbouncer を使用しています。しかし、これにより、キャッシュの問題のように見えるクライアント (PHP>PDO>Doctrine) に別の問題が発生します。
この「起動時間」を短縮する方法はありますか? 新しい接続ごとに構成がロード/作成されているように見えますが、これは合理的ではないようです。