zid
zid11mo ago

Confirmation regarding filtering on paginated queries

Just wanted to confirm how filtering works in a very specific scenario. When 1. not using an index and 2. using a paginated query, will applying a filter on this query perform a full table scan or just on the current page?
3 Replies
zid
zidOP11mo ago
In other words, will the following .filter perform a full table scan or scan through the initialNumItems setting in the paginationOpts
users = await db
.query("users")
.filter((q) => q.neq(q.field("name"), "Alex"))
.order("desc")
.paginate(paginationOpts);
users = await db
.query("users")
.filter((q) => q.neq(q.field("name"), "Alex"))
.order("desc")
.paginate(paginationOpts);
lee
lee11mo ago
It will scan the table until it finds initialNumItems that satisfy the filter. If most people have name!=Alex, it will read approximately initialNumItems. If most people are named Alex, it may scan the entire table. (edited because i missed the q.neq)
zid
zidOP11mo ago
Ah i see, thank you Lee!

Did you find this page helpful?