$lookup + $unwind optimization

Hi Jose,

Was reading the online documentation around this 2 stages.

I’m assuming there is no need for a stage to exclude empty arrays in the “as” field after a $lookup stage i.e. the $lookup+$unwind optimization implicitly gets rid of this?

Is that what the comment “unwinding: { preserveNullAndEmptyArrays: false }” in the explain plan implies?

Thanks

Hi,

Yes, it is. preserveNullAndEmptyArrays is an option you can pass to $unwind, which defaults to false.

José Carlos

1 Like