punn
punn2y ago

Querying _creationTime range in large table

What are the suggested patterns for querying a large table by _creationTime? I would like to specify a startTime and endTime but my current query still iterates over the whole table, which exceeds the limit and throws an error.
3 Replies
lee
lee2y ago
i think you can do await db.query("table").withIndex("by_creation_time", q => q.gt("_creationTime", lowerBound).lt("_creationTime", upperBound)),collect()
punn
punnOP2y ago
worked like a charm, thanks!
Michal Srb
Michal Srb2y ago
It's kinda buried but this built-in index is documented at the end of this doc: https://docs.convex.dev/database/indexes/
Indexes | Convex Developer Hub
Indexes are a data structure that allow you to speed up your

Did you find this page helpful?