开发者

What is meant by indexing in MongoDB?

开发者 https://www.devze.com 2023-01-27 08:01 出处:网络
To be true, After typing the Question title only, i had a look about DB indexing in Wiki. Now i know something about Indexing in general. But, still i have some questions on MongoDB indexing.

To be true, After typing the Question title only, i had a look about DB indexing in Wiki. Now i know something about Indexing in general. But, still i have some questions on MongoDB indexing.

What is indexing in MongoDB? What it will exactly do, If i index a collection? What i can do with indexing in MongoDB? Will i able to use it for searching specific data?

Can anyone explain it with the below set of documents in a 开发者_开发知识库Collection in some MongoDB?

{ "_id":"das23j..", "x": "1", "y":[ {"RAM":"2 GB"}, {"Processor":"Intel i7"}, {"Graphics Card": "NVIDIA.."}]}

Thanks!!!


An index speeds up searching, at the expense of storage space. Think of the index as an additional copy of an attribute's (or column's) data, but in order. If you have an ordered collection you can perform something like a binary search, which is much faster than a sequential search (which you'd need if the data wasn't ordered). Once you find the data you need using the index, you can refer to the corresponding record.

The tradeoff is that you need the additional space to store the "ordered" copy of that column's data, and there's a slight speed tradeoff because new records have to be inserted in the correct order, a requisite for the quick search algorithms to work.

For details on mongodb indexing see http://www.mongodb.org/display/DOCS/Indexes.

0

精彩评论

暂无评论...
验证码 换一张
取 消