#[Aggregate]: Insertion slow?

7 messages · Page 1 of 1 (latest)

uncut island
#

I want to backfill some new TableAggregates, but the backfill migration is taking 1.5 seconds for each batch of 100 documents. I'm using namespace, sortkey and sumvalue in the aggregate. When doing regular non-aggregate migrations on this table, execution was about 100 times faster.

Is this expected? It's gonna take a while for all 130k documents in my production environment!!

torn loom
#

there is a non-trivial overhead to cross-call into components right now. we're working on optimizing it over the next 4-8 weeks, so it should speed up quite a bit. this is probably what's impacting this the most

#

we'll just keep optimizing this in the background over time, however, with no code changes needed on your end

uncut island
#

Thanks, sounds good :)) so reading from components should become faster as well?

Also, for some reason I can't leave out bounds when calling functions on a namespaced aggregate, e.g.
const max = await watchPercentageByChannel.max(ctx, { namespace: channelId});

gives the following TS error:

  Property 'bounds' is missing in type '{ namespace: Id<"channel">; }' but required in type '{ bounds: Bounds<number, Id<"watchSession">>; }'.ts(2345)```


The function itself runs without problems on e.g. the dashboard. I am on the latest version of `aggregates` and have just reinstalled node modules to troubleshoot
#

I ran into this problem previously and solved it by just passing bounds: {}, as an argument, but it doesn't match what's stated in the docs or shown in the examples (where bounds can be omitted altogether)

torn loom
#

basically, every component runs in its own v8 isolate, and so cross-calling between the isolates isn't very fast right now (10-15ms? maybe a bit more sometimes?)