Skip to content

Allow batched aggregate.at calls #31

@djbalin

Description

@djbalin

Proposal: Allow multiple aggregate.at calls on the same aggregate to be carried out in the same environment.

Background: Currently, each call to an aggregate/a component spins up an independent v8-isolate environment (as per Ian's statement in Discord). This means that calling aggregate.at multiple times can lead to very slow execution speeds.

Example:
In our production app, for example, the code below takes ~800 ms on a TableAggregate of approx 10,000 documents (measured by console.time):

  const indexes = [0, 1, ..., 30] // array of length = 30

  const atIndexes = await Promise.all(
      indexes.map((i) => profileSubmissionAggregate.at(ctx, i)),
   );

Note: the code above is taken from the shuffle example in the Aggregate docs: https://github.com/get-convex/aggregate/blob/main/example/convex/shuffle.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions