fakesilentF
Convex Community5mo ago
15 replies
fakesilent

Ordered listings created within the last 6 days gives too many bytes read error

export const getTopRatedListings = internalQuery({
  handler: async (ctx) => {
    const sixDaysAgo = Date.now() - 6 * 24 * 60 * 60 * 1000;

    return ctx.db
      .query("listings")
      .withIndex("by_cashflow")
      .order("desc")
      .filter((q) => q.gte(q.field("_creationTime"), sixDaysAgo))
      .take(1);
  },
});

schema
    ...,
    monthlyCashflow: v.optional(v.number()),
  })
    .index("by_cashflow", ["monthlyCashflow"])


This is giving me the following too many bytes read error:

Error: [CONVEX Q(fetchListings:getTopRatedListings)] [Request ID: 49905af9f0732044] Server Error
Uncaught Error: Too many bytes read in a single function execution (limit: 16777216 bytes). Consider using smaller limits in your queries, paginating your queries, or using indexed queries with a selective index range expressions.


I am genuinely puzzled on how to do this without running into this error. ~6k documents
Was this page helpful?