The indexes on both collections should allow the matching documents to be queried more efficiently on both the game1 and game2 collections.
If more game* collections exist this approach can be further expanded to add additional $lookup stages, however the performance of a pipeline with additional $lookups may not be great and the Data Model may need refinement instead.
Thank you, that was exactly what I was looking for. However your last comment made me think about restructuring the data model.
I have multiple games where each game has its own set of stats, as you saw on the original post. The two solutions I have thought of so far is one collection per game (what I currently have) or a single collection where each document has all the stats for all games. The reason I didn’t choose the second option was because it will end up being quite many read and write operations on that collection, but I also think I would want to avoid using $lookup on multiple collections because I might end up having 20 games.
Before settling on the data model it would be helpful to evaluate how you intend to interact with your data. If you will be interacting with each game’s collection frequently and only infrequently querying across games the per-game model is likely fine.
If you will frequently be interacting with all games’ data by uuid then a single collection may make more sense as you can later shard this data if collection “size” becomes a concern.