@adonis_avance
In a large dataset, the first scenario where the _id of the message is saved in an array in both the sender and receiver documents is likely to be faster. This is because when fetching messages, the array can be used to quickly find the relevant messages, without the need for an index lookup. In the second scenario, a search needs to be performed on the sender or receiver _id, which would require an index lookup and could be slower.
It’s worth noting that there may be other ways to structure the data for even faster retrieval, such as using a separate collection for messages or using a combination of indexing and query optimization. However, for the two scenarios proposed in the question, the first one is likely to be faster in a large dataset.