Describing the problem in another way:
1. Weak filter function followed by accumulate over a large stream of 3 million transactions is slow.
We have a weak filter function ( for functional compliance) in 3 out of 145 rules over 3 million transactions.
2. Every transaction which passes the weak filter function enables an accumulate over a large stream of 1 to 3 million facts.
transactions after peak hours ( say after 1 PM in day) navigate the full stream of 2 million transactions for accumulate.
Every insert new fact starts a huge RETE rebalancing because of accumulate across full stream.
3. Conditional Element of time in accumulate
Conditional function of accumulate is being used ( it appears) to include or exclude the tuple from accumulate RETE. It will go to the beginning of the full stream or RETE network even though I dont want to accumulate any more after that.
4. Order of transactions in stream
Our transactions are time ordered in stream. Hence, we were hoping that conditional element of accumulate will stop the search after 3 minutes or 20 minutes are over rather than search the whole RETE for 24 hours.
5. Our workaround
We have created smaller streams of 5 minutes, 15 minutes and 30 minutes to make some of the rules fast in addition to 24 hour stream. This works and is fast.
We implemented hashmap for storing the last transaction for each of the entities. This makes a few of the rules a million times faster especially.
Can you suggest a more permanent and better solution to our challenge of working with large fact base based streams which are time ordered and where we want to accumulate values for individual entities ( like cards, ATMs, accounts etc) over 4 minutes, 1 hour or 24 hours.
Thanks for your help once more,
Rao