Hi,
We create a sample for chat service, and for all dialogue we store messages and activity in the database. Until now we put all in the same collections, but if we get lot of users, it can be consume lot of CPU / Network.
So is it better to create many collections and all users watch one of them for modification, or create an huge collection and all users watch it for modification (and filter only after) ? We read collection and watch modification on it (via realtime API) Any best practice for this case ?
Hi
You can keep using 1 collection. With proper indexes, all queries will be quick. We have seen collections with millions of documents with no performance implication. Regarding realtime, if you subscribe, you only get notifications about documents you have read permission to. So if you enable document security, and make sure to only give read permissions to those who need it, all should be fine.
Thanks for the complete answer 👍
[Solved] One huge collection or lot of small ?
Recommended threads
- I am using s3 for app storage but is it ...
_APP_STORAGE_DEVICE=s3 puts everything to the s3 storage but i need to be able to keep the function builds and site in the local and not waste the cloud storage...
- Websocket error Realtime
Hi peeps, I am trying to create realtime updates and I am having websocket error Code is below this msg
- Realtime not processing messages
When subscribing to realtime events of database, the client's websocket receives the messages in the websocket feed, but doesn't call the specific message handl...