有人可以帮助我了解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。但是有人可以让我知道它是如何工作的(也许在上面的例子中),以及如何有效地存储和检索键值对。
谢谢。
答案 0 :(得分:0)
您可以阅读以下文档:
What’s New in MongoDB 3.0 Part 3: Performance & Efficiency Gains, New Storage Architecture
MongoDB Docs WiredTiger Compression
简而言之:WiredTiger在将数据持久保存到磁盘时会压缩数据