2
Postgres的全文搜索性能似乎取決於您使用字典,這裏是一個例子Postgres的全文搜索性能問題
我的表包含了60000項
默認德語字典(僅停用詞,我認爲)
SELECT title FROM sitesearch s, to_tsquery('german','holz') query WHERE query @@ searchtext LIMIT 10
查詢計劃
Limit (cost=247.14..282.99 rows=10 width=21) (actual time=1.286..1.534 rows=10 loops=1)
-> Nested Loop (cost=247.14..1358.57 rows=310 width=21) (actual time=1.278..1.512 rows=10 loops=1)
-> Function Scan on query (cost=0.00..0.01 rows=1 width=32) (actual time=0.019..0.019 rows=1 loops=1)
-> Bitmap Heap Scan on sitesearch s (cost=247.14..1354.68 rows=310 width=570) (actual time=1.237..1.452 rows=10 loops=1)
Recheck Cond: (query.query @@ s.searchtext)
-> Bitmap Index Scan on sitesearch_searchtext_idx (cost=0.00..247.06 rows=310 width=0) (actual time=0.871..0.871 rows=1144 loops=1)
Index Cond: (query.query @@ s.searchtext)
Total runtime: 1.815 ms
8 row(s)
Total runtime: 13.414 ms
這是相當快
我的字典德國ispell的
CREATE TEXT SEARCH DICTIONARY pg_german (
TEMPLATE = ispell,
DictFile = german,
AffFile = german,
StopWords = german
);
的複合詞的支持使
dictfile:319018個字
綴文件:1290線
禁用詞:264個字
SELECT title FROM sitesearch s, to_tsquery('public.pg_german','holz') query WHERE query @@ searchtext LIMIT 10
查詢計劃
Limit (cost=247.14..282.99 rows=10 width=21) (actual time=1.263..1.578 rows=10 loops=1)
-> Nested Loop (cost=247.14..1358.57 rows=310 width=21) (actual time=1.255..1.556 rows=10 loops=1)
-> Function Scan on query (cost=0.00..0.01 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=1)
-> Bitmap Heap Scan on sitesearch s (cost=247.14..1354.68 rows=310 width=570) (actual time=1.229..1.495 rows=10 loops=1)
Recheck Cond: (query.query @@ s.searchtext)
-> Bitmap Index Scan on sitesearch_searchtext_idx (cost=0.00..247.06 rows=310 width=0) (actual time=0.896..0.896 rows=1144 loops=1)
Index Cond: (query.query @@ s.searchtext)
Total runtime: 1.818 ms
8 row(s)
Total runtime: 1,520.428 ms
查詢計劃是快速的... 1,5s總運行時間?加載/初始化字典需要很長時間嗎?如何加快這個過程?
謝謝!
因爲9.1現在已經出來,但我找不到任何有關ispell速度的信息,有沒有什麼改進?感謝名單! – kertal 2011-09-17 11:15:24