I’m making a mongoDB (with pymongo) which is constantly being filled with date-sensitive data. I’d like to retrieve this data, but making sure it’s always the freshest data I’m getting.
With .find() I should be able to do this, right?
Also, should I index the db?
As for efficiency, would ten thousand concurrent connections to a mongodb be a problem?
Any small advice much appreciated!
The mongo cursor is infact a stream from the DB so as you assume doing:
Will get a stream of newest records. There is a problem with timeouts here. If you were to use this as a pubsub function you are better off using tailable cursors etc.
You should always index the field. No question there since you are querying on the field by applying a sort to it.
This last line is extremely subjective. I am unsure how I can answer this without knowing your document, expected index size, working set size, server setup and a whole tonne of other things.