[rules-users] Why all rule condition fired when insert object in drools session?

FrankVhh frank.vanhoenshoven at agserv.eu
Thu Jan 24 06:38:11 EST 2013


Hi Zhao,

You could insert a helper fact and use it as a first pattern in your
conditions. That way, the engine will not evaluate too many patterns from
rules that are not to be executed.

When
    ActiveGroup(name == "GroupA")
    ...
Then
    ...

Implications
 * You will have to take care of the status of ActiveGroup and update its
value yourself. Make sure you do it at the appropriate moment. (Low salience
rule?)
 * You would have to re-evaluate the need for the agenda-group. Its
functinos are taken over by the fact, do you still need the group?
 * Whether it will improve performance or not is a whole different question
all together and is depending on your ruleset. I never did severe testing on
it, but imho, there are certainly cases where the agenda-group is faster
than the fact. As a rule of thumb, I would say that if you do a lot of
update/modify calls in your consequences, you might get an improvement by
blocking the evaluation of patterns early.

Regards,
Frank

PS You could also create a different fact per agenda-group. It should be
mildly faster while providing quite a lot less flexibility.



--
View this message in context: http://drools.46999.n3.nabble.com/Why-all-rule-condition-fired-when-insert-object-in-drools-session-tp4021769p4021779.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list