amutu / zhparser

zhparser is a PostgreSQL extension for full-text search of Chinese language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

搜索比较慢,求助怎么优化

jianfengye opened this issue · comments

我大概有50w的数据,搜索起来特别慢

master=> SELECT id FROM question            WHERE to_tsvector('testzhcfg', content) @@ to_tsquery('testzhcfg', 'sdfdsfsdf') order by id desc limit 10;
 id
----
(0 rows)

master=> select count(*) from question;
 count
--------
 504440
(1 row)

求助能怎么优化?

commented

你的这个操作并没有使用pg的gin索引,所以会很慢。
建议你看一下pg的全文检索文档,explain确保查询走了gin索引