Reputation: 207
I am wondering what is better to do. I have a pulled back a query like this:
Array
(
[_id] => MongoId Object
(
[$id] => 4eeedd9545c717620a000007
)
[field1] => ...
[field2] => ...
[field3] => ...
[field4] => ...
[field5] => ...
[field6] => ...
[votes] => Array
(
[whoVoted] => Array
(
[0] => 4f98930cb1445d0a7d000001
[1] => 4f98959cb1445d0a7d000002
[1] => 4f88730cb1445d0a7d000003
)
)
)
Which would be faster:
in_array()
to find the right id?Upvotes: 0
Views: 115
Reputation: 310
It Depends on a lot of factors that I suggest you test but IMO most of the time it would be faster to just do 2 querys
Upvotes: 1
Reputation: 561
Depends on the size of the array being returned / searched.
Also different servers are doing the work, what do you mean by faster? At what scale?
Upvotes: 0