MongoDB 8.3 arrayIndexAs cuts $map-with-index overhead by up to 31%
MongoDB 8.3 adds arrayIndexAs, which hands $map the element index directly instead of forcing a $range plus $arrayElemAt workaround. On arrays of 10,000 to 320,000 elements the new form runs 15-31% faster, but the gain drops to about 5% under ten concurrent aggregations.
- arrayIndexAs passes the index straight into $map, removing $range and $arrayElemAt
- On a 320,000-element array: 102 ms vs 134 ms, a 1.31x speedup
- With 10 parallel queries the gap shrinks from 13% to about 5%
- Under FCV 8.2 arrayIndexAs returns a generic parser error with no FCV hint
Read next
Software