Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教:关于pg_trgm中文支持问题 #17

Closed
GYWang1983 opened this issue Dec 13, 2017 · 6 comments
Closed

请教:关于pg_trgm中文支持问题 #17

GYWang1983 opened this issue Dec 13, 2017 · 6 comments

Comments

@GYWang1983
Copy link

参考 中文模糊查询性能优化 by PostgreSQL trgm 及网上其他文章,都说pg_trgm已经支持multi-byte character,只要collate和ctype不是C就行,但是我自己实验还是不行

wechatimg18

我在本地安装的10.1版本,或者是在Aliyun创建的9.4版本,结果都是一样
请问可能是什么地方出了问题?

@yjhatfdu
Copy link

PG10我自己测试在有的平台上也不行,可以试试自己安装一个pg_bigm插件 ,对中文支持更好,而且对于一个字及两个字的like优化更好,缺点是只支持like不支持正则

@digoal
Copy link
Owner

digoal commented Jan 27, 2018

image

@qzren1982
Copy link

@yjhatfdu 好插件,我试试

@qzren1982
Copy link

@digoal
我有一个问题请教一下,我看了你的很多文章,涉及到很多pg的索引,
btree,hash,gin,gist,brin,但是我感觉在传统的行业应用中
像那些有排序和分页情况下的查询。除了btree索引之外,好像没有更好的索引可用,但是btree表现还不是太好。
我们一般都是使用类似的查询
select col1,col2,col3
from table
where col1 between :1 and :2
and col2 like 'XXX%'
order by col1 desc
limit 20;
取一页的记录,
1,我们设置一个索引 IDX_123 (COL1,COL2 varchar_pattern_ops),
这个索引的问题主要是: COL2 like ‘XXXXXX%' 这个如果很精确的话 就慢,
因为根据索引倒叙扫描的块更多。

2,如果单独再设置一个索引 IDX_456(COL2,col1)
对于col2更加精确的条件,可以找这个索引,

3,如果col2 LIKE 'YYYY%'; 处于1和2之间,优化器就很难选择哪一个更好了

@lustres
Copy link

lustres commented Nov 23, 2018

环境 macOS 10.14.1
版本 PostgreSQL 10.5 on x86_64-apple-darwin18.2.0, compiled by Apple LLVM version 10.0.0 (clang-1000.10.44.4), 64-bit

image

@hooopo
Copy link

hooopo commented Nov 30, 2018

@lustres 看来mac系统的都有这个问题

@digoal digoal closed this as completed Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants