Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7908889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:08:28+00:00 2026-06-03T12:08:28+00:00

I am wondering what is better to do. I have a pulled back a

  • 0

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:

  1. Pull that entire array in 1 query and use in_array() to find the right id?
  2. Pull everything from the first query except the votes and then do another mongodb query to see if that id exist in the array?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:08:29+00:00Added an answer on June 3, 2026 at 12:08 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have this line and I'm wondering if there's better way to do
I was wondering how to better write code like this so that it leverages
I was wondering what is better in this case? I have to read in
I have define a collection like List ids. I am wondering which is better
I was wondering which type would have better performance and which you think should
I was wondering if anyone would have a better suggestion for keeping a feature
I was wondering if in chrome code we have some better way to detect
I have been wondering what is better way of using code. Is there any
Wondering if anyone has a solution to this 2010 bug. I have a project
I'm wondering what a better design is for the intersection table for a many-to-many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.