Skip to content
Back

[SOLVED] The maximum document in the collection is 5000?

  • 0
  • Databases
Riconalada
17 Feb, 2023, 14:04

Hello everybody !

I insert data into a collection with the Nodejs sdk, in total I have 6250 records to do. The data is added to the collection well (I have a progress bar and the insertion goes to 6250), I have no error message and the program terminates. But the collection stops at 5000 records. Is there a limit of documents in a collection please?

thank you for help.

TL;DR
There seems to be a confusion regarding the maximum number of documents in a collection in the support thread. The user initially thought there was a limit of 5000 documents, but it was clarified that there is no such limit. The remaining records (1257) were successfully added to the collection. The suggestion was also made to implement Cursor pagination for better performance and to avoid relying on the count operation. This can be done by following the guidelines provided in the documentation. Additionally, it was recommended to consider having a separate "count" collection to keep track of the number of documents, as counting all the time can be detrimental to performance. The
Riconalada
17 Feb, 2023, 15:08

I have just checked, indeed in the "Documents" tab in the collection , it displays 12 lines of 417 pages maximum which makes 5004 records and displays at the bottom left "total results": 5000 , when we go to the "Usage" tab shows me 6257 documents

Riconalada
17 Feb, 2023, 15:11

Another problem is when I use the List Documents api "databases.list_documents('[DATABASE_ID]', '[COLLECTION_ID]')" , it returns me "total results: 5000". and the list of documents.

I want to check the number of documents in the list to see if there were 5000 or 6257 but this one only returns me 25 documents? Why ?

VincentGe
17 Feb, 2023, 15:12

You can have more documents, we just show you 5000+ instead of the exact number.

VincentGe
17 Feb, 2023, 15:12

The count operation in SQL will iterate over every single document

VincentGe
17 Feb, 2023, 15:12

And counting all the time is terrible for performance. That said, if you need to keep track of number of documents, we recommend you actually have a separate "count" collection that you can use.

VincentGe
17 Feb, 2023, 15:13

You can either have every document create and delete operation trigger an Appwrite function to increment or decrement a counter, or to pass all document operations through an Appwrite function to do the same type of operation.

VincentGe
17 Feb, 2023, 15:13

This way you will have O(1) time checking number of documents, instead of O(N)

Riconalada
17 Feb, 2023, 15:16

Thank you Vincent, indeed I am a beginner and it seems strange to me. I didn't know if I could access a maximum of 5000 documents. In any case, the remaining 1257 are, that's what matters to me. Thanks for the increment idea !

VincentGe
17 Feb, 2023, 15:17

We also recommend you do Cursor pagination for the same reason, so you don't rely on count. This is what GitHub does, too. https://appwrite.io/docs/pagination#cursor-pagination

Riconalada
17 Feb, 2023, 15:20

Yeah great ! Thank you so much Vincent !

VincentGe
20 Feb, 2023, 19:47

[SOLVED] The maximum document in the collection is 5000?

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