加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – GiST和GIN索引之间的差异

发布时间:2020-12-13 16:35:23 所属栏目:百科 来源:网络整理
导读:我正在实现一个表,其中包含一个数据类型为tsvector的列,我试图了解哪个索引更适合使用? GIN还是GiST? 在查看postgres documentation here时,我似乎得到了: GiST更新和构建索引的速度更快,而且不如杜松子酒更准确。 GIN更新和构建索引的速度较慢,但??
我正在实现一个表,其中包含一个数据类型为tsvector的列,我试图了解哪个索引更适合使用?

GIN还是GiST?

在查看postgres documentation here时,我似乎得到了:

> GiST更新和构建索引的速度更快,而且不如杜松子酒更准确。
> GIN更新和构建索引的速度较慢,但??更准确。

好的,那么为什么有人想要一个gist索引字段而不是杜松子酒呢?如果要点可能会给你错误的结果?必须有一些优势(外部表现)。

当我想要使用GIN和GiST时,有人可以用外行的方式解释吗?

我认为我不能比 the manual更好地解释它:

In choosing which index type to use,GiST or GIN,consider these
performance differences:

  • GIN index lookups are about three times faster than GiST

  • GIN indexes take about three times longer to build than GiST

  • GIN indexes are moderately slower to update than GiST indexes,but about 10 times slower if fast-update support was disabled […]

  • GIN indexes are two-to-three times larger than GiST indexes

该链接指向当前手册,引用来自版本9.4,而您的链接是版本9.1(出于某种原因?)。

手册中的尺寸和性能估计似乎略显过时 – 并且已被删除。
With Postgres 9.4 the odds have shifted substantially in favor of GIN
release notes of Postgres 9.4包括:

  • Reduce GIN index size (Alexander Korotkov,Heikki Linnakangas) […]

  • Improve speed of multi-key GIN lookups (Alexander Korotkov,Heikki
    Linnakangas)

请注意,有special use cases需要一个或另一个。

你误解了一件事:你从来没有用GiST索引得到错误的结果。索引对哈希值进行操作,这可能导致索引中出现误报。这应该只与文档中的大量不同单词相关。在任何情况下重新检查实际行后都会消除误报。 The manual:

A GiST index is lossy,meaning that the index may produce false
matches,and it is necessary to check the actual table row to
eliminate such false matches. (PostgreSQL does this automatically when needed.)

大胆强调我的。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读