-2
請幫我用mongoDB中的索引。MongoDB。如何設置索引?
有一個收集了800,000個文件。 有一個很長時間的請求。大約5秒鐘!
{
"$or":[
{
"performer":"534ba408f9cd0ecb51711673",
"$or":[
{
"performersRole":"534ba30bf9cd0ec151a69522"
},
{
"performersRole":{
"$exists":false
}
}
]
},
{
"performersRole":"534ba30bf9cd0ec151a69522",
"notShowInToDo":{
"$ne":true
}
}
],
"taskTime":{
"$gte":1409774400,
"$lt":1409860799
},
"$and":[
{
"$or":[
{
"department":{
"$in":[
"5356134ef9cd0e4805672a15",
"53561368f9cd0e4b05645f3f",
"53a0357ff9cd0e670537c4b7",
"53a03594f9cd0e6705389449"
]
}
},
{
"department":{
"$exists":false
}
}
]
},
{
"$or":[
{
"salon":"534f7b3bf9cd0e311e77896f"
},
{
"salon":{
"$exists":false
}
}
]
}
],
"isDone":{
"$ne":true
}
}
要添加哪些索引進行優化?感謝您的任何建議!
幾乎快要這種格式的所有文件:
{
"_id": "541da66cf535a4a8569dd0ed",
"title": "test task",
"taskTime": NumberLong(1411229292),
"client": "53f876b2f535a4187f9e1264",
"salon": "534f7c3cf9cd0e91206dd948",
"track": "541da66cf535a4a8569dd0ec",
"department": "53a0357ff9cd0e670537c4b7",
"type": "invitePBP",
"performersRole": [
"534ba30bf9cd0ec151a69522"
],
"notShowInToDo": true,
"@createTime": NumberLong(1411229292),
"@updateTime": NumberLong(1411229292)
}
你最好提供更多的細節。例如,你製作了哪些索引?哪些字段有獨特的價值? ... – Wizard 2014-09-20 16:09:47
添加到示例問題文檔 – jeka5555 2014-09-20 16:31:40
除了非常奇怪的構造,你可能只是[閱讀關於索引的文檔](http://docs.mongodb.org/manual/core/indexes/)。 – 2014-09-21 09:56:18