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
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Storage files aren’t showing on mobile
hi, what can be the problem? i have a storage and there are images in it, the permissions are read for All Users, everything is fine on desktop, but on mobile t...
- Delete storage files all at once
I am using Appwrite Cloud. I want to delete all storage files in my bucket similar to how I can select all documents in a collection and delete them all at once...