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
- SELF HOSTING ISSUE, DATA NOT MIGRATING T...
Hey, devs, I recently tried to migrate my cloud instance to a self hosted version but my data is not transferred fully only the table structure is transferred ...
- No Document ID?
Hi I have a self hosted appwrite. My documents get a document ID but are not visible in the console. I don't know why this happens and how to fix this
- AppwriteException: Invalid query: Query ...
```js console.log(typeof interaction.user.id) console.log(interaction.user.id) const user_check = await TablesDB.listRows({ databaseId: "db", ...