简体   繁体   English

JSONB GIN索引上的Postgres CLUSTER?

[英]Postgres CLUSTER on JSONB GIN index?

I'm trying to evaluate using Postgres with one JSONB column vs a more traditional relational model (each fields being one column). 我正在尝试将Postgres与一个JSONB列和一个更传统的关系模型(每个字段都是一列)一起使用进行评估。 I recently found that CLUSTERing on an index in the relational model (in this case an index on one column) helped read performance a lot, understandably. 我最近发现,对关系模型中的索引(在本例中为一列的索引)进行聚类有助于提高性能,这是可以理解的。

From my understanding, running CLUSTER ON will actually reorder how the table is stored physically, based on the index specified. 据我了解,运行CLUSTER ON实际上会根据指定的索引重新排序表的物理存储方式。 What I was hoping to know is, if I run CLUSTER ON , how exactly will the table be reordered? 我希望知道的是,如果我运行CLUSTER ON,那么将如何对表重新排序? Is there any way to know before I actually execute the command, or is this more of a try-it-and-see scenarios? 在实际执行命令之前,是否有任何方法可以知道?还是更多的“尝试一下”方案?

If it's helpful, we are using the jsonb_path_ops operator. 如果有帮助,我们将使用jsonb_path_ops运算符。

Thanks! 谢谢!

I doubt you can cluster on a GIN index because there is no natural ordering in the index. 我怀疑您可以基于GIN索引进行聚类,因为索引中没有自然顺序。 Clustering physically reorders on the order of the index and gin indexes don't have an ordering on them per se. 按索引和gin索引的顺序对物理重新排序进行聚类本身没有顺序。

So I would be extremely surprised if this worked. 因此,如果这样做有效,我将感到非常惊讶。 I think you would need a btree index instead. 我认为您将需要一个btree索引。

Now, you could do a functional index on an attribute of the jsonb and cluster on that, I think. 现在,我认为您可以对jsonb的属性进行功能索引并在其上进行集群。

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

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