【问题标题】:How does MongoDB store data efficiently?MongoDB如何高效地存储数据?
【发布时间】:2019-07-07 17:38:21
【问题描述】:

有人可以帮我了解一下 mongoDB 如何有效地存储和检索数据。

在文档中,它显示了以下示例。 插入:

db.inventory.insertMany([
   // MongoDB adds the _id field with an ObjectId if _id is not present
  { item: "journal", qty: 25, status: "A",
   size: { h: 14, w: 21, uom: "cm" }, tags: [ "blank", "red" ] },
  { item: "notebook", qty: 50, status: "A",
   size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank" ] },
  { item: "paper", qty: 100, status: "D",
   size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank", "plain" ] },
  { item: "planner", qty: 75, status: "D",
   size: { h: 22.85, w: 30, uom: "cm" }, tags: [ "blank", "red" ] },
  { item: "postcard", qty: 45, status: "A",
   size: { h: 10, w: 15.25, uom: "cm" }, tags: [ "blue" ] }
 ])

然后检索:

  db.inventory.find( { status: "D" } )

我知道它在内部使用 BSON。但是有人可以告诉我这是如何工作的(可能是上面的例子)以及如何有效地存储和检索键值对。

谢谢。

【问题讨论】:

  • 这是由存储引擎处理的(可能是 WiredTiger。不太可能是 MMAPv1)。这些是谷歌搜索的关键字。

标签: json mongodb nosql bson


【解决方案1】:

您可以阅读这些文件:

What’s New in MongoDB 3.0 Part 3: Performance & Efficiency Gains, New Storage Architecture

MongoDB Docs WiredTiger Compression

WiredTiger Storage Engine FAQ

简而言之:WiredTiger 在将数据持久化到磁盘时会对其进行压缩

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 2012-07-30
    • 2017-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多