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

  • Home
  • SEARCH
  • 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 8263309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:03:22+00:00 2026-06-08T04:03:22+00:00

I have been tasked with porting data from a MongoDB database to a MySQL

  • 0

I have been tasked with porting data from a MongoDB database to a MySQL database.
(There are strong reasons for porting – so it has to be done).

The MongoDB collection:

  • Has approx 110 Million documents
  • Weighs 60 GB in size
  • Has indexes for important properties
  • Is running of a Windows 2008 standalone separate server which is not serving any production traffic

The Setup that we have tried:

  • An Large Amazon EC2 Win2008 Server instance with 7.5 Gigs of RAM / 8 Gigs of Page File
  • A C# console app which converts the MongoDB data to a local MySQL database

We pick up 1K documents at a time in memory from the MongoDB, do the necessary processing and then save them to the MySQL db doing batch writes of 500 at a time.

The problem that we are facing is that every 2.5 M docs, the server chokes up and Mongo responds very slowly – timing out the app’s data fetch operation (Free RAM gets over by the time 1M documents are processed)

We are moving ahead slowly by killing the mongod process and starting it again every 2.5M records when it crashes – but I bet we’re doing something wrong.

Question:

Should I move the Mongo Server to a Linux based Large Instance and MySQL to the Amazon RDS for this and rewrite the conversion app in PHP? Will it help?

The reason we decided to keep it all on one box was the latency issue of having different servers on different boxes – but I guess that is moot if the box is choking up.

What other things can I try / tips I can use?

Thanks for reading this far!

— Update 01 —

Its been approximate 6 hours since I restarted my app and have made the following change:

  1. Increased Mongo Read count from 1,000 to 10,000 records at a time. .skip(10K).limit(10K)
  2. Removed all indexes from the MySQL target database.
  3. Increased the Windows page size from 4 Gigs to 8 Gigs

My memory is at 100% consumption but the app is running still. (Last time it croaked in 52 mins). Mongo eating 6.8 Gigs of RAM, MySQL – 450 Megs and the converter app – 400 Megs (approx values).

Processed 11M records so far – but the speed has gone down to 370 records / sec from approx 500 records / sec.

Next steps are going to be to isolate both the Mongo and MySQL servers to separate boxes and – keeping all of them in the same Amazon availability zone to minimize latency.

— Update 02 —

We made some changes in code to use the Mongo Cursor and letting it auto increment automatically as against doing a .skip().limt() ourselves. This greatly sped up the process and we were doing 1250 records per second from 300 odd earlier. However, the application started consuming too much memory and would run out of RAM and crash and needed to be restarted after every 2M records.

We used this code snippet:

var docs = db[collectionName].Find(query);
docs.SetBatchSize(numOfResultsToFetchAtATime);
foreach (var d in docs) {
  // do processing
}

So what this does is fetch ‘numOfResultsToFetchAtATime’ records at a time – but then progresses automatically in the loop and fetches the next set of records. Mongo takes care of this progression using a Cursor and hence it is a lot faster.

However, we have still not been able to successfully port this.
Will post my reply with code when that happens properly.

— Update 03: Success —

We finally used @scarpacci’s suggestion of doing a mongoexport.
Do remember that it is essential that the mongodb is on a linux box and not a windows box.

We first tried doing a mongoexport from Windows on the local MongoDB and no matter what we tried, it would fail at different places for one large collection (13Gigs+)

Finally, I restored the DB on a Linux box and mongoexport worked like a charm.

There is no Json -> MySQL converter – so that much we had to do.
With a little tweaking, we were able to use our previous app and read the files and write to MySQL directly. It was quick and relatively error free.

We had some issues with the large files, but breaking down the 13GB file to 500 Meg long files helped with that and we were able to migrate all data to MySQL successfully.

Many thanks to everyone for spending time helping us out. Hope that this explanation helps someone in the future.

  • 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-08T04:03:24+00:00Added an answer on June 8, 2026 at 4:03 am

    Have you considered using mongoexport then performing some sort of Bulk Insert into MySQl? Not sure if that is available in MySql, but we perform something similar in SQL Server all the time. Might make the dumps / inserts easier to break apart and optimize? Just a thought….

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

Sidebar

Related Questions

I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
I have been tasked with porting a large Java codebase to the Android platform.
I have been tasked with converting some scripts referencing an Informix database to be
I have been tasked to develop an interactive website using java & mysql: using
I have a large codebase that I've been tasked with porting to 64 bits.
I have been tasked to replace the hardware an existing Apache/Tomcat/MySQL application is running.
I have been tasked with writing an ADP application using Access. The back-end data
I have been tasked with building a new web project from scratch, with the
I have been tasked with finding a good fit for a database to use
I have been tasked to send data to a 3rd Party web service, they

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.