Description
When you do a rebuild (but i also guesse if you have a new async projection later on in je project, since it looks like the same code at first sight) you have a querry like this, to get the events needed to apply =>
select d.data, d.type, d.mt_dotnet_type, d.seq_id, d.id, d.stream_id, d.version, d.timestamp, d.tenant_id, d.correlation_id, d.causation_id, d.headers, d.is_archived, s.type as stream_type from public.mt_events as d inner join public.mt_streams as s on d.stream_id = s.id and d.tenant_id = s.tenant_id where d.seq_id > :p0 and d.seq_id <= :p1 and d.type = ANY(:p2) and d.is_archived = FALSE order by d.seq_id limit 500
p0 is your current position, p1 is your high watermark and p2 is your array of matching event types.
But for example when you only have matching events by type where you have a high sequence gap between then this querry takes really long and can result in time outs. Should it be a good idea to have a index on type by default? or per haps limit the p1 and p0 gap in some pre defined limit until the high watermark is being achieved?
Also the limit of 500 can be overriden by configuration of your BatchSize of the projection witch can result in more cases like this happening.
Example of batch where it went wrong for our projection to rebuild.