Hello
Is there somewhere information of the Complexity of array/set/object operators? or how they work internally?
I am doing some benchmarks and i get some not expected results.
For example i have an array of integers and i reduce that array to itself
doing nothing just re-construct the array using reduce and $concatArrays
Everytime i do {$concatArrays $$newArray [anumber] }
Thought it would be similar with Java’s ArrayList that is O(1) with dynamic array but its not.
There is no $push(works only in $group the one we have) in aggregation framework so i used $concatArrays
Adding one member each time is so slow,unusable for large arrays
($concatArrays is super fast if arrays are big,but one by one adding is so slow)
For 200000 members it takes 240sec
For 100000 members it takes 23sec
For 50000 members it takes 6 sec
For 10000 members 168.411066 msec
How to add an element to an array to the end or in specific location?
Is it possible without $concatArrays which is slow for repeated calls?
Also mongoDB offers set operators without sets but on arrays,
Everytime i do one set operation i should think it as array->set->array
If i have a reduce that does set operations on an array at every step all array will become set
and then back to array? Or will remain set(internally)?
If its not kept internally as set it will be very slow to repeat many set operations on an array.
Thank you