title: WSO2 CEP window time 1 day
body: <p>I am evaluating different possible solution for ATM Card transaction fraud detection with input load of around 50000 per second and response time few seconds. </p>
  
  <p>WSO2 CEP looks better fit for overall solution, but stuck with problem of memory &amp; performance  as I am new to WSO2 CEP so please suggest if there is better way of doing below in CEP WSO2/CEP.</p>
  
  <p>in order to detect fraud we have to capture data aggregation over a time period of 1 day which is causing either memory overflow or performance hit. </p>
  
  <p>1) Below causing out of memory as CEP tries to keep all record in memory for whole day  </p>
  
  <pre><code>from instream#window.time(1 day) 
  select sum(amount) as totalAmt;
  </code></pre>
  
  <p>2) Below causing performance hit as it tries to load all records from table for doing some. </p>
  
  <pre><code>define table instream_table (....) from ( datasource,table,cache policy) ;
  
  from instream#window.length(1) join instream_table
  on instream.card_id==intable.card_id
  select sum(instream_table.amount) as totalAmt;
  </code></pre>
  
  <p>worst thing I have noticed that CEP fires <code>select * from instream_table</code> instead of adding even where clause for card_id, Where I was expecting CEP to intelligent enough to fire <code>select sum(amount) from instream_table where card_id=xxxxx</code></p>
  
  <p>i have looked at documentation for window in WSO2 CEP but could not find any way to optimize this as it looks like WSO2 CEP tries to everything in memory. </p>
  
  <p>let me know if there is any work around or better solution to achieve this. I have looked at other CEP engines like esper but seems every body is doing this in same manner. </p>