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.
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
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 ?
You can have more documents, we just show you 5000+ instead of the exact number.
The count operation in SQL will iterate over every single document
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.
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.
This way you will have O(1) time checking number of documents, instead of O(N)
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 !
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
Yeah great ! Thank you so much Vincent !
[SOLVED] The maximum document in the collection is 5000?
Recommended threads
- I lost my account, only thing i have is ...
So i had this project on appwrite for my web project called Islami zindagi, but i havent used it in a while, now i tried to login, but i could not remember the ...
- 403 The current user has been blocked.
Hello, I have a free plan; I've tried to access my project and I get the message "403 The current user has been blocked." I have database, sites, and auth in us...
- [Bug?] row_already_exists (409) after ma...
Hi, I'm experiencing a confusing issue with Appwrite Cloud Setup: A `tournaments` table with a composite UNIQUE index on (tournament_name, date). Steps to rep...