2

I've been reading about ensureindex (Mongodb: when to call ensureIndex?) , (Pymongo / MongoDB: create index or ensure index?) and mongodb documentation, but i havent come to a conclusion about the use of ensureindex. Doesnt mongodb create an Id for every document? Why do i need another index? In case I have a document like this:

{
    "Name": "Jon Secada",
    "Date of Birth": "09-19-1983",
    "Address": "1 chemin des Loges",
    "City": "VERSAILLES"
}

Whats the advantage of calling ensureindex on "name" for example?

4

1 回答 1

1

您可以在您选择的字段上获得更有效的搜索,但会消耗额外的内存和磁盘空间。

于 2015-11-02T17:22:08.690 回答