I am using MongoDB as DataBase for my application
I have a question with respect to Mongo DB find operation .
Assume if i have two / three same records on a field say symbol in the collection present in the Database .
db.collection.find( { “symbol”: “GOOG” })
On What basis does the Mongo DB shows the First record ??
Edited part
I am having Mongo DB present in my Test Environment and as well as in Production Environment with the same data .
my question is ,
when i do
db.bios.find( { “name”: “FOOGY” } )
There is a difference in the Data that is displayed (the first record ) in two environments ??
Please let me know why there is a variation in the Data that is dislayed in two environments when issued the same commnad
db.bios.find( { “name”: “FOOGY” } )
Please let me know is there any thumb rule that what record should be sown first ??
Unless you explicitly sort, it’s whatever order they happen to be stored in on disk (called natural order). If you care what the order of the returned records is, provide the
sortoption to yourfind.To address your updated question: yes, if you have the same docs stored in to separate MongoDB instances, they definitely can come back in a different from one another. Even a single MongoDb instance can return the docs in a different order over time as documents are relocated on disk due to updates.