我想知道做什么更好。我有一个这样的查询:
Array
(
[_id] => MongoId Object
(
[$id] => 4eeedd9545c717620a000007
)
[field1] => ...
[field2] => ...
[field3] => ...
[field4] => ...
[field5] => ...
[field6] => ...
[votes] => Array
(
[whoVoted] => Array
(
[0] => 4f98930cb1445d0a7d000001
[1] => 4f98959cb1445d0a7d000002
[1] => 4f88730cb1445d0a7d000003
)
)
)
哪个会更快:
- 在 1 个查询中拉出整个数组并用于
in_array()
查找正确的 id? - 从第一个查询中提取除投票之外的所有内容,然后执行另一个 mongodb 查询以查看该 id 是否存在于数组中?