MongoDB的哈希索引与升序索引相比是否没有性能优势?

huangapple go评论76阅读模式
英文:

is mongodb hashed index has no performance benefit compared to ascending index?

问题

这是要翻译的内容:

  • Is this still true for Mongodb version 6 for now?? or was there an enhancement?

    • 对于当前的 MongoDB 版本 6,这是否仍然成立?或者是否有改进?
  • How do I prove that how hashed index works internally?

    • 如何证明哈希索引在内部是如何工作的?
  • do I have to use other storages (like redis) for better performance?

    • 我是否需要使用其他存储(如 Redis)以获得更好的性能?
英文:

I heard in somewhere that unlike other dbms' hashed index, MongoDB's hashed index
uses b-tree internally, so there is no performance benefit compared to normal ascending index. I was shocked, but soon I noticed that MongoDB version was 3.4 in that article.

My Question:

  • Is this still true for Mongodb version 6 for now?? or was there an enhancement?
  • How do I prove that how hashed index works internally?
  • do I have to use other storages (like redis) for better performance?

答案1

得分: 1

我理解混淆的原因,但在回答你的问题之前,有一件更重要的事情值得注意。

在MongoDB中,散列索引被添加以满足特定的目的,即在使用分片时有效地分布数据。这就是它们使用“B树”结构的原因,这样它们可以有效地使用树枝作为分片。


有了这个前提,让我们回答你的问题:

对于当前的Mongodb版本6,这个说法仍然有效吗?还是有改进?

是的,这仍然有效,因为它们是根据上述方式设计的。

我怎样证明散列索引的内部工作原理?

不确定如何回答这个问题,MongoDB是开源的,如果你愿意,可以自己查看源代码。或者你可以相信我 MongoDB的哈希索引与升序索引相比是否没有性能优势?

我是否需要使用其他存储(如Redis)以获得更好的性能?

这是一个非常广泛的问题,一般来说,像Redis这样的内存数据库在“标准”数据库上会提供更好的性能,因为它们具有网络开销。然而,内存数据库也有自己的问题,标准数据库没有。

此外,它们通常具有较少的功能,因为它们更“简单”。

如果我们能够得到关于你尝试解决的问题、你设计的架构以及数据规模的详细描述,那么更容易建议哪种数据库适合你的需求。

英文:

I understand where the confusion comes from, but before I answer your questions there is a more important thing worth noting.

Hashed Indexes in MongoDB were added to serve a specific purpose, efficiently distributing data across shards when using sharding. This is the reason they use a "B tree" structure, so they can effectively use the tree branches as shards.


With that out of the way, let's answer your questions:

>Is this still true for Mongodb version 6 for now?? or was there an enhancement?

Yes, this will remain the case as they are designed this way (as explained above).

>How do I prove that how hashed index works internally?

Not sure how to answer that, MongoDB is open source and you can dive into the source code yourself if you wish. Or you can believe me MongoDB的哈希索引与升序索引相比是否没有性能优势?

>do I have to use other storages (like redis) for better performance?

This is a very broad question, in general an in memory db like Redis will give better performance over "standard" db's as they have network overhead. However in memory DB's have their own issue's that a "standard" DB does not.

Additionally they usually have less features as they are "simpler".

It will be easier to advice which DB fits your needs if we had a proper description of the problem your trying to solve, the architecture you've designed and the scale of your data.

huangapple
  • 本文由 发表于 2023年7月31日 22:26:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804575.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定