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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:43:22+00:00 2026-06-18T00:43:22+00:00

I have a mongodb collection with realtime data with a short lifecycle. When I

  • 0

I have a mongodb collection with realtime data with a short lifecycle.
When I need them I also want to delete the once I find,

Here’s pseudo code using morphia wrapper:

for(LogEntity log: mongo.find(LogEntity.class, "grabMe", true)){
    mongo.delete(mongo.createQuery(LogEntity.class).filter("logId", log.id));
    //Do work and dispose the log
}

I’m running some tests on this and its really difficult to simulate a heavy load because this is part of Google GCM.

This is running in a Runnable that are fed from an ScheduledExecutorService scheduleAtFixedRate every 2 sec.

Is this going to work or is there a better way to do this. How is the find() working in this situation. Will I mess up the find()’s internal array by deleting from it. If there are many LogEntity I cannot hold them in memory.

  • 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-18T00:43:23+00:00Added an answer on June 18, 2026 at 12:43 am

    heavy load logging with short lifecycle, I will choose capped collection. in this situation, you cannot delete a document in the capped collection.

    on the other hand, if you wanna choose normal collection for logging and do a timed clean up, your find and delete loop is slow. if your code is foreach item in collection.find(query) {collection.remove({_id:item._id};} use collection.remove(query) method instead.

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

Sidebar

Related Questions

I have a MongoDB collection and need to find the max() value of a
I have a MongoDB collection with data that was not saved through my Derby
I have the following collection named 'CanvasCollection' in mongoDB and I want to get
I have a MongoDB collection Marks with fields student_id,Subject,Mark. I want to the average
I need to have collections such as: client1.users client1.images client2.users client2.images MongoDB supports Collection
Here is my case: I have a MongoDB collection in Node.Js. Let's say three
I have MongoDB.BsonDocument, i want to convert that BsonDocument to List of collection, how
I have a MongoDB collection with various data in it. (about millions) These data
I have 57M documents in my mongodb collection, which is 19G of data. My
The problem is that i need two different data sets of one mongodb collection

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.