有人可以帮我理解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。但有人可以让我知道它是如何工作的(可能是上面的例子)以及如何有效地存储和检索键值对。
谢谢。
你可以阅读这些文件:
What’s New in MongoDB 3.0 Part 3: Performance & Efficiency Gains, New Storage Architecture
MongoDB Docs WiredTiger Compression
简而言之:WiredTiger在将数据保存到磁盘时压缩数据