Cơ BảnMongoDB iconMongoDB

Multikey index là gì?

Multikey index được tạo khi index field chứa array. MongoDB index từng element trong array, giúp query match element nhanh hơn.

Ví dụ:

javascript
db.posts.createIndex({ tags: 1 })
db.posts.find({ tags: "mongodb" })

Cần cẩn thận với compound multikey indexes vì array nhiều chiều hoặc nhiều array fields có thể tạo index entries lớn, ảnh hưởng write performance và storage.

Xem toàn bộ MongoDB cùng filter theo level & chủ đề con.

Mở danh sách MongoDB