MongoDB索引概述
This is my Fourth MongoDB post, in the first post we looked at how we can install MongoDB as a Windows Service, In the second post we looked at how we could do UPSERTs with MongoDB, In the third post we looked at how to sort results in MongoDB.
This post is about indexing in MongoDB, we are going to take a look at how to create indexes and how to see if the indexes are being used by MongoDB. Every index that you create in MongoDB is a secondary index, this is because MongoDB creates the default _id index for all collections. The _id index is a unique index on the _id field, you cannot delete the index on _id. MongoDB indexes use a B-tree data structure
Besides a regular one field index, you can also create the following indexes in MongoDB
1 Indexes on Embedded Fields
2 Compound Indexes
3 Multikey Indexes
4 Unique Indexes
5 Sparse Indexes
Before you go crazy and start adding indexes on every possible field in your collection, keep in mind that just like in regular databases, the more indexes you have the slower you write operations will be. Every update and insert will be a little slower because the indexes will have to be maintained.
Some limitations: A collection can't have more than 64 indexes.Index keys can't be larger than 1024 bytes. This includes the field value or values, the field name or names, and the namespace.
Let's go take a look at some of these indexes
This post is about indexing in MongoDB, we are going to take a look at how to create indexes and how to see if the indexes are being used by MongoDB. Every index that you create in MongoDB is a secondary index, this is because MongoDB creates the default _id index for all collections. The _id index is a unique index on the _id field, you cannot delete the index on _id. MongoDB indexes use a B-tree data structure
Besides a regular one field index, you can also create the following indexes in MongoDB
1 Indexes on Embedded Fields
2 Compound Indexes
3 Multikey Indexes
4 Unique Indexes
5 Sparse Indexes
Before you go crazy and start adding indexes on every possible field in your collection, keep in mind that just like in regular databases, the more indexes you have the slower you write operations will be. Every update and insert will be a little slower because the indexes will have to be maintained.
Some limitations: A collection can't have more than 64 indexes.Index keys can't be larger than 1024 bytes. This includes the field value or values, the field name or names, and the namespace.
Let's go take a look at some of these indexes
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-752948/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mongodb 概述MongoDB
- MongoDB 索引MongoDB索引
- mongodb索引MongoDB索引
- ORACLE索引概述Oracle索引
- mongodb索引使用MongoDB索引
- mongoDB的索引MongoDB索引
- MongoDB之索引(地理資訊索引)MongoDB索引
- MongoDB之索引(全文索引)MongoDB索引
- MongoDB之索引(過期索引)MongoDB索引
- MongoDB之索引(唯一索引)MongoDB索引
- MongoDB索引,效能分析MongoDB索引
- mongodb建立索引和刪除索引和背景索引backgroundMongoDB索引
- mongodb 如何檢視索引MongoDB索引
- MongoDB ( 五 )高階_索引MongoDB索引
- MongoDB之索引(簡介)MongoDB索引
- MongoDB索引實戰技巧MongoDB索引
- 快速掌握mongoDB(三)——mongoDB的索引詳解MongoDB索引
- 【MongoDB學習筆記】MongoDB索引那點事MongoDB筆記索引
- MongoDB系列一(索引及C#如何操作MongoDB)MongoDB索引C#
- MongoDB索引優化詳解MongoDB索引優化
- MongoDB中的定時索引MongoDB索引
- 005.MongoDB索引及聚合MongoDB索引
- MongoDB索引的簡單理解MongoDB索引
- MongoDB慢查詢與索引MongoDB索引
- MongoDB複合索引詳解MongoDB索引
- mongoDB研究筆記:複製集概述MongoDB筆記
- 【Mongo】MongoDB索引管理-索引的建立、檢視、刪除MongoDB索引
- MongoDB索引與優化詳解MongoDB索引優化
- mongodb資料庫如何建立索引?MongoDB資料庫索引
- MongoDB中複合索引結構MongoDB索引
- MongoDB如何在後臺建立索引MongoDB索引
- MongoDB技巧——不要到處使用索引MongoDB索引
- MongoDB副本集故障恢復機制概述MongoDB
- 【TUNE_ORACLE】Oracle索引設計思想(二)索引過濾列概述Oracle索引
- MongoDB學習之豐富的索引MongoDB索引
- mongodb索引及查詢優化分析MongoDB索引優化
- mongodb 重複建立索引不報錯MongoDB索引
- 【TUNE_ORACLE】Oracle索引設計思想(一)索引片和匹配列概述Oracle索引