Reference of last transaction happened (moving records from MongoDB to MySQL)

15 views
Skip to first unread message

forumu...@gmail.com

unread,
Jul 9, 2014, 6:29:08 AM7/9/14
to mongod...@googlegroups.com
I want to retrieve the 100 (n number) records from MongoDB and store it in MySQL. Want to do this for every 5 minutes, and every time have to continue from where that last record transaction happened.

What is the best way to do this with MongoDB? [In oracle, can do this by having a reference of row_id]

Thanks in advance for suggestions/inputs.

Will Berkeley

unread,
Jul 11, 2014, 11:05:05 AM7/11/14
to mongod...@googlegroups.com
Hi. Could you help me understand what you're trying to accomplish? Are you trying to slowly migrate records from MongoDB to MySQL? Why does it need to happen only every 5 minutes? Is the MongoDB instance live while this is happening, i.e. is it accepting inserts, removes, or updates?

You can keep a cursor alive without activity for more than 5 minutes (in fact, indefinitely) and just pull results as needed, but heed the warnings on the linked page about long-running cursors in MongoDBs returning the same document multiple times. You could also store the _id or some other marker of the last record seen and then do a search for newer records at the next interval.

-Will
Reply all
Reply to author
Forward
0 new messages