My question is, do we really have to do this? When fetching the data I use the search params. Will subscribing to all the data at once load all the data and reduce the performance of the app?
Oh I see. Actually I’m taking the ready to a constant and loading the component only when it’s ready. I use this inside a container (Use react-komposer).
So do you think fetching the data through a method be a better solution?
Not necessarily. A method gets you a snapshot of your collection based on the query you make at that time. If that’s OK for your use case, go with it. On the other hand, a subscription gives you reactive changes to your collection over time. Only you can apply your understanding of your use case to decide the best way to get your data.
The general rule is: publish as much of your collection that you’ll need in your client for the duration of a particular page view. While in that view you would perform find() locally to display subsets of that data as required.
However, if the scope of data that could be required by a page is very large (unusual) and your local find() is both very selective and infrequent the balance shifts towards making a subscription request each time and using a local non-selective find(). As @robfallows says, you have to make a judgement call on your use case. Subscriptions are relatively heavy-weight (and often require a wait indicator).
Finally, the title of your post suggest a slight misunderstanding. It’s not the size of the collection in MongoDB that is the issue, it is the number of documents that you decide to publish from your collection (but maybe you meant that).