Hi all,
I’m encountering a “rate limit exceeded” error in a Fauna collection where I store parts for purchase orders. The collection currently holds over 40,000 records, and the structure of the records looks like this:
{
Plnt: "redacted",
FunctionalLocation: "redacted",
Department: "redacted",
EquipmentNumber: "redacted",
EquipmentDescription: "redacted",
MaterialNumber: "redacted",
MaterialDescription: "redacted",
Bin: "redacted",
MPN: "redacted",
ItemCategory: "redacted",
ManufactSerialNumber: "redacted",
ModelNumber: "redacted",
Location: "redacted",
Price: redacted
}
I have an index set up to query based on department and location and my query would look like:
let set = collection.index(<department>, <location>) { fieldsToProject }
set.pageSize(50)
set.distinct()
If an after cursor is returned with the first response, I run a while loop to continue querying until no after cursor is returned like so:
Set.paginate(<after>, 50)
However, I’ve started hitting the rate limit with my current queries, and I’m on the pay-as-you-go plan, which allows for up to 500 read ops per second.
My questions are:
- What are some optimization strategies I could employ to reduce the number of read operations (e.g., adjusting my query structure, pagination approach, or index usage)?
- Should I consider breaking this query into smaller batches or limit the frequency of requests?
- Is there a more efficient way to structure my collection or index that would help avoid hitting this limit?
Thanks,
Ryan