Relative Content

Tag Archive for pythonmongodboptimizationindexingpipeline

MongoDB date type VS string type range searching speed

I have a collection in MongoDB that has ~2Million Documents. Average document size is 28KB. There are several fields but we are concerned with three fields namely – “time”, “test_time” and “arr”. “time” is a string field and stores the date and time in string format, “test_time” is a Date field and stores the exact same date and time in Date format. “arr” is an array of objects with ~10 fields in each object. Average length of an “arr” is ~5. We are concerned with only one of those fields called “name” , so basically arr.name
The pipeline is as follows –
a match stage on the “time” field with greater than and less than some particular dates X and Y. After that a projection field of projecting only {arr.name:1, _id:0}