Back

[Solved] One huge collection or lot of small ?

  • 0
  • Realtime
  • Storage
Mickaël LT
30 Mar, 2023, 09:28

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 ?

TL;DR
The user was asking whether it is better to have one large collection or multiple smaller collections for a chat service. The response suggests that using one collection with proper indexes is recommended, as it won't have performance issues even with millions of documents. In terms of real-time updates, if document security is enabled and read permissions are given only to those who need it, there should be no problems.
joeyouss
30 Mar, 2023, 09:41

Hi

joeyouss
30 Mar, 2023, 09:47

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.

Mickaël LT
30 Mar, 2023, 11:58

Thanks for the complete answer 👍

Mickaël LT
30 Mar, 2023, 11:58

[Solved] One huge collection or lot of small ?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more