简体   繁体   English

Postgres Gin Index 读取性能

[英]Postgres Gin Index read performance

The official doc states that: 官方文档指出:

One advantage of the separate-column approach over an expression index is that... Another advantage is that searches will be faster, since it will not be necessary to redo the to_tsvector calls to verify index matches.与表达式索引相比,单独列方法的一个优点是......另一个优点是搜索会更快,因为不需要重做 to_tsvector 调用来验证索引匹配。

Why does a gin expression index to_tsvector('english', body) has to "verify index matches"?为什么 gin 表达式索引to_tsvector('english', body)必须“验证索引匹配”? It seems that index are automatically updated after every update/insert, All indices have same update issue and this might not be the point to be concerned.似乎每次更新/插入后索引都会自动更新,所有索引都有相同的更新问题,这可能不是要关注的问题。

I think this deals with the "recheck" which is necessary, since the GIN index scan is potentially lossy: it will return values that contain all elements from the tsvector you search for.我认为这涉及必要的“重新检查”,因为 GIN 索引扫描可能有损:它将返回包含您搜索的tsvector中所有元素的值。 All these rows get rechecked to see if they really match the tsquery .所有这些行都被重新检查以查看它们是否真的与tsquery匹配。 That means that the to_tsvector function is evaluated for all rows that are returned by the index scan.这意味着针对索引扫描返回的所有行评估to_tsvector function。

As the docs say, that is more important for GIST than for GIN.正如文档所说,这对 GIST 比对 GIN 更重要。

GIN indexes can still need to be rechecked if work_mem is too small to hold the entire bitmap so they go lossy.如果 work_mem 太小而无法容纳整个 bitmap,则仍需要重新检查 GIN 索引,因此它们 go 有损。 They will also need to be rechecked if the pattern uses relative position indicators like <-> , <2> etc.如果模式使用相对的 position 指标(如<-><2>等),也需要重新检查它们。

It might also need rechecking if you have many & ed together tokens and it just decides to recheck the more common of them rather than bothering with all the bitmaps for them (I'm not sure if actually does this here or not--I've never witnessed it for @@ but without having inspected the entire code I can't rule out the possibility) or maybe if you have complicated boolean tsquery expressions.如果您有许多& ed together 标记,它可能还需要重新检查,它只是决定重新检查它们中更常见的,而不是为它们烦恼所有位图(我不确定这里是否真的这样做——我'我从来没有为@@目睹过它,但没有检查整个代码我不能排除这种可能性)或者如果你有复杂的 boolean tsquery 表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM