你能创建一个包含 _id 或 key 的复合索引吗?
Can you create a compund index including _id or key?
假设我有以下文件:
{_id: "mycollection/key",
_key: "key",
users: ["userKeyA","userKeyB","userKeyC"]
}
我可以为 _id 和 users 创建持久索引以加快我对用户密钥的查找时间吗?
是的,你可以。
db.<collection>.ensureIndex({fields:["users", "_key"], type:"persistent");
假设我有以下文件:
{_id: "mycollection/key",
_key: "key",
users: ["userKeyA","userKeyB","userKeyC"]
}
我可以为 _id 和 users 创建持久索引以加快我对用户密钥的查找时间吗?
是的,你可以。
db.<collection>.ensureIndex({fields:["users", "_key"], type:"persistent");