Can't count collections with more than 600 000 documents

Sorry for the late response,

There is a limit to how much computation you can do within one transaction. Fauna is not an aggregation (OLAP) type of database but a distributed OLTP which means at this point aggregations are going to do quite some work behind the scenes. In this case, the Count results in an O(n) operation.

To count more documents you’ll have to start paginating and continue counting from within the application.

Count(Paginate(Documents(....), { size: 100000}))

The max pagesize is 100000 though so to count further you’ll have to go over at least 6 pages in this case. You will receive an ‘after’ cursor to do so. The warning in the docs actually mentions the O(n) nature of Count: Count | Fauna Documentation

2 Likes