postgres:复合全文本/ btree索引 [英] postgres: Composite fulltext / btree index

查看:103
本文介绍了postgres:复合全文本/ btree索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一列上进行全文搜索并在另一列中排序。如果我分别索引这两列,postgres不能在这个查询中使用两个索引。有没有办法创建一个可用于这种情况的组合索引?

b
$ b

您可以通过 btree_gin contrib模块,Postgres不能使用GIN索引进行排序。来自文档


在PostgreSQL当前支持的索引类型中,只有B-tree可以
产生排序输出 - 其他索引类型返回
中的匹配行,未指定,依赖于实现的顺序。


I want to do a fulltext search on one column and sort in a different column. If I index these two columns separately postgres can't use both indexes in this query. Is there a way to create a composite index that could be used in this scenario?

解决方案

Unfortunately not.

While you can attach scalar columns to a GIN index via the btree_gin contrib module, Postgres can't use a GIN index for sorting. From the docs:

Of the index types currently supported by PostgreSQL, only B-tree can produce sorted output — the other index types return matching rows in an unspecified, implementation-dependent order.

这篇关于postgres:复合全文本/ btree索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆