Aggregate Lookups - Performance - Data Type of the Join Columns

When we use $lookup in aggregation to join between two collections is there a performance impact due to data types of the joining columns?

Will a $lookup between two collections on a Integer column perform better than a String or Date Column?

Are there any guidelines on this with performance in mind?

As with any programming language and system, all other variables being equal, comparing 2 integers will be faster than comparing 2 strings. One such variable that might affect that is indexes. Comparing indexed strings will be a lot faster than comparing 2 non-indexed numbers.

Date (when not formatted as String) are usually on par with integers.

1 Like