I have a collection with a lot of docs in it. So I created an Index for my collection so I can deal with only the docs for a specific client within my system, based on the collections clientId field. Although, I want to filter down even further to only the docs for this client with a ts value within a time range.
I’ve found a way to do this, by creating an index with a term of “clientId”, and a value of “ts”. From the documentation it looks like the values in an index are used for ordering, or range kind of uses. I tried to put “ts” as a term in the index, but Fauna rejected it.
With this index, I queried it only looking for documents from today. (Though I do need to add in the ability to query for documents with ts between two Time values.)
CollectionName.byMyIndexName(Client.byId(“some_client_id”)).where(.ts > Time(“2023-07-24T00:00:00Z”)).count()
This works, but is slow. It takes a few seconds. I’m concerned that my index isn’t putting the records in order of their ts, so Fauna isn’t able to get to just the records for the time range quickly.
What am I doing wrong? How should I be querying in FQLv10 (FQLX) for documents for a specific .clientId and with a ts value within a specific Time range?
Thank you in advance for your help!