关于二级索引,Cassandra vs MongoDB? [英] Cassandra vs MongoDB in respect of Secondary Index?

查看:246
本文介绍了关于二级索引,Cassandra vs MongoDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

博客中,我看到下面的语句

At blog I see below statement


二级索引是MongoDB中的一类构造。这使
易于索引存储在MongoDB中的对象的任何属性,即使
是嵌套的也是如此。这使得根据这些
次要索引进行查询非常容易。 Cassandra仅对二级
索引提供粗略的支持。次要索引也仅限于单列和
相等比较。

Secondary indexes are a first-class construct in MongoDB. This makes it easy to index any property of an object stored in MongoDB even if it is nested. This makes it really easy to query based on these secondary indexes. Cassandra has only cursory support for secondary indexes. Secondary indexes are also limited to single columns and equality comparisons.

我有两个相关的问题。

I have two related questions on it .



Cassandra仅粗略地支持二级索引。

Cassandra has only cursory support for secondary indexes.


不确定是什么使Mongo拥有比仅具有粗略支持的cassandra更好的支持?

Not sure what makes Mongo to have better support than cassandra which just has cursory support ?



二级索引[Cassandra]也限于单列

Secondary indexes[Cassandra] are also limited to single columns


我对上述陈述的理解是,cassandra仅支持单列而不是复合列的二级索引

My understanding on above statement is that cassandra supports secondary indexes only on single column not on composite column



二级索引[Cassandra]也仅限于相等比较。
我相信这意味着Mongo也可以使用索引来实现大于/小于运算符的操作,但是cassandra仅限于相等性?

Secondary indexes[Cassandra] are also limited to equality comparisons. I believe it means Mongo can use index for greater/lass than operation also but cassandra is limited to equality ?


我的理解是Mongo以类似于RDBMS的方式实现了secondar索引,但是不确定cassandra是如何在高层实现的?

My understanding is Mongo implements the secondar index in similar fashion as RDBMS but not sure how cassandra implements it at high level ?

推荐答案

Mongo与Cassandra是,Mongo是主/从数据库,而Cassandra是无主系统。

The major difference between Mongo & Cassandra is that, Mongo is mater/slave DB Vs Cassandra is a masterless system.

所有的写操作都发生在Mongo中的单个PRIMARY节点上,该节点被复制到SECONDARIES。因此,整个数据在单个节点中可用,因此具有辅助索引&通过它进行查询变得更加简单(就像其他RDBMS一样)。因此,它支持针对辅助索引的所有类型的查询。当我们转向Mongo Sharded系统而不是简单的副本集时,情况变得越来越复杂。

Having said that, all writes happen to a single PRIMARY node in Mongo which gets replicated to SECONDARIES. So the entire data is available in a single node and hence having a secondary index & querying by it becomes simpler (just like any other RDBMS). Hence it supports all types of queries against a secondary index. It gets complicated as we move towards a Mongo Sharded system vs a simple replicaset.

对于Cassandra,数据将基于分区键分布到多个节点中。现在,建立二级索引仅与该特定节点上的数据有关,并且不知道其他节点中的数据。因此查询二级索引中的列会导致分散收集,因为匹配的数据可能位于任何节点中。由于不涉及任何分区键来限制节点数量,因此这种类型的查询将非常慢(取决于群集大小)。

In case of Cassandra, the data is distributed into multiple nodes based on the partition key. Now building a secondary index is only relative to data on that particular node and is unaware about the data in other nodes. So querying for a column in secondary index results in scatter gather, because the matching data could lie in any node. As no partitioning key is involved to restrict number of nodes, this type of query would be very slow (depending on the cluster size).

因此在Mongo中进行RANGE查询没什么大不了的,因为整个数据都在PRIMARY节点中可用。而对于Cassandra,二级索引的范围扫描将意味着扫描该给定节点中的每一行。因此,范围查询可能需要很长时间,因此不被支持。

So having a RANGE query in Mongo is no big deal, because the entire data is available in PRIMARY node. While Cassandra the range scan of secondary index would mean scanning every row in that given node. So a range query can take forever and hence not supported.

这篇关于关于二级索引,Cassandra vs MongoDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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