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 9169913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:56:39+00:00 2026-06-17T15:56:39+00:00

I face some problem with my query in mongodb(pymogno driver). Here is my problem:

  • 0

I face some problem with my query in mongodb(pymogno driver).

Here is my problem:
I have to insert(update) about 100 million(100000000) documents to mongodb per day.
I gave up on using update the same key field I have to update append, and revised to use bulk insert (update performance is slower than bulk insert).

Here is sketch scheme in my db.

{_id:xxx, F1:1 , F2:"test1", TS": 2011/01}
{_id:xxx, F1:1 , F2:"test2", TS": 2011/02}
{_id:xxx, F1:2 , F2:"test1", TS": 2011/03}
{_id:xxx, F1:3 , F2:"test1", TS": 2011/04}
{_id:xxx, F1:2 , F2:"test1", TS": 2011/05}
.....
(4 billion up or more)

When I query, I just want to retrieve the latest TS group by F1(field1).

I know that “group” aggregation framework can do that, but I have sharding my db and group operation not allow in sharding db.

I also tried to use map-reduce to do that, but it is not providing good enough query performance.

The only query I am using is “$in” operation.

db.test.find({"F1":{"$in":[1,2,3,....]}})

It retrieves all docs in the target array, but i only want to get the latest document per key F1.

{_id:xxx, F1:1 , F2:"test2", TS": 2011/02}
{_id:xxx, F1:2 , F2:"test1", TS": 2011/05}
{_id:xxx, F1:3 , F2:"test2", TS": 2011/03}

How can I get that?

ps.
The target array might contain a million elements that I want to bulk query.

Is there is good way to do that?

  • 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-17T15:56:40+00:00Added an answer on June 17, 2026 at 3:56 pm

    While there’s no single step solution to this problem as you can’t use the aggregation framework in a shard as you mentioned (and it likely wouldn’t perform well even if it did), you might want to explore a solution like:

    • Create a new document collection which will be used as your index (but not an actual MongoDB index).
    • Inside this collection, you will store one document per unique F1 value. The document contains a reference to the most recent Document in your primary collection. You can use a conditional update to create (when necessary) the index document or update it. Use a query to find the document and match only if the timestamp is less than (or equal) to the newest document being inserted for that value. (maybe
    • You’d then use the “index collection” to fetch the latest document references for each F1 value.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i face problem with System.currentTimeMillis( ) in my project i write some code here
I face some problem when I use submit. Here is the code using some
I have previous experience with MATLAB, but the problem that I face is some
Hi I face some problem with my flash script. Here is my code onFrame
I have a project that's been using font-face without problem for some time. Today
I have some problem with font-face that are loaded are deform my div height.
I face some layout differences in IE and in Chrome. I have searched Stack
Last day my head judge me because he face with some problem that he
I have some @font-face webfonts on my site. The fonts and the CSS code
I face following problem with three20 photobrowser app : 1: Some time images are

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.