0

I have the following query window in my application. I want an update on when the Employee event is coming the first time (a new Employee ) OR if there is any update for an existing Employee. My application is getting a lot of updates and I suspect the below Window is not keeping only the last two records in memory and due to that memory uses increase with time. Is there any way I can ensure that only last two records are available in Window?

@name('stmtUpdateEmployee') select * from Employee#groupwin(empId)#length(2)
    where
    prev(1, age) <> age OR
    prev(1, dept) <> dept OR
    prev(1, address) <> address OR
    prev(1, empId) is null;
Sushil
  • 327
  • 1
  • 3
  • 20

1 Answers1

0

I suspect the below Window is not keeping only the last two records in memory and due to that memory uses increase with time

Your suspicion is correct! There will be more than the last two records in memory ... depending on the data, a lot more.

As mentioned in section Esper Reference 5.6.8, the groupwin(empId) line in the select clause ...

select * from Employee#groupwin(empId)#length(2)

creates a separate data window per key value, and the query planner creates a hash index on Employee, essentially resulting in holding onto all the employee events that have a unique empId.

So this will grow with the number of unique employees ... there will be at least 2 * the number of unique employees events (since this is a length of 2, the latest employee event and the previous employee event are in memory.)

Dakotah North
  • 1,324
  • 12
  • 29
  • 1
    Hi, should we say that there could be more than 2 events present in memory for same key even we are looking only latest 2? – Sushil Oct 03 '22 at 23:36