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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:30:06+00:00 2026-06-14T07:30:06+00:00

I insert bunch of docs into one collection, then a cron job moves them

  • 0

I insert bunch of docs into one collection, then a cron job moves them to another collection.

The reason I do this is that there is a non-indexed collection that needs to store data fast, the second collection is indexed and hence slow for inserts, so the cron job moves the data.

I use the following script to move data

db.smalldaily.find().forEach(function(doc){db.largedaily.save(doc);db.smalldaily.remove(doc);});

The problem is right after moving the data is completed, mongod seems to crash, when I log into the mongo shell and type db.large and then press the TAB button for auto-completing the collection name, mongodb goes to coma and I need to restart the mongod service to make it work.

Am I doing something wrong or the rumors that mongodb is still immature are partially true?

I’m using MongoDB shell version: 2.2.1 on CentOS

  • 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-14T07:30:07+00:00Added an answer on June 14, 2026 at 7:30 am

    So, this is basically running as server side javascript that creates a massive forEach loop in the shell iterating across those 1 million+ documents and I am betting that the amount of (non-mapped) memory is sky high while this is running.

    If you ran this outside the shell using a driver instead you would likely not see the problems at all. Does the migration complete and then not clean up the memory? If so, then that is probably the issue.

    Changes are coming in the next release (2.3+) to make the shell far more performant, but for now it would probably be a better idea to do this via a driver instead of internally in the shell. For one thing it would immediately be more efficient to do this in batches rather than iterating one at a time.

    With all that being said, if this is easily reproducible, and especially if you can provide an example data set, this would be perfect fodder for a bug report so that the developers can figure out why the shell is barfing when processing this loop.

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

Sidebar

Related Questions

I'm trying to insert a bunch of rows into an empty UITableView in one
I have a bunch of data which will insert into a table. This issue
INSERT INTO [Temp].[dbo].[Student] ([Fname], [Lname], [Gender]) VALUES (N'Aname', N'Alname', N'Male') GO This codes workes
INSERT MODE i have check box in one tr. and another dropdown control in
I'm trying to insert a bunch of data into a SharePoint list. The List
so I have to insert a bunch of records from a data source that
How can I insert a whole bunch of rows into an XML variable without
I've got a bunch of files that have sentences ending like this: \@.Next sentence
I've got a datasource that has a bunch of insert functions. Each function takes
Pulling my hair out here... I need to insert a bunch of html into

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.