[rules-users] Performance consideration in rule writing

Wolfgang Laun wolfgang.laun at gmail.com
Mon Dec 26 09:19:57 EST 2011


See below.

2011/12/26 Zhuo Li <milanello1998 at gmail.com>

>  Hi, team,****
>
> ** **
>
> I have some quick questions here regarding performance best practices of
> rule writing. See below two pieces of rules:****
>
> ** **
>
> Rule “1”****
>
>          Salience 100****
>
>          No-loop true****
>
>          When $txn : data(sourceid ==
> 5&&txnjustify==”995”&&eval(creditOption($txn)==1)&&eval(isGCSwitch($txn))&&isCurrencyEquals($txn)==0&&compareToPostThreshold($txn)==2);
> ****
>
>          Then****
>
>                    …****
>
>          End****
>
> ** **
>
> Rule “2”****
>
>          Salience 100****
>
>          No-loop true****
>
>          When $txn : data(sourceid ==
> 5&&txnjustify==”995”&&eval(creditOption($txn)==1)&&eval(isGCSwitch($txn))&&isCurrencyEquals($txn)==0&&compareToPostThreshold($txn)==1);
> ****
>
>          Then****
>
>                   …****
>
>          End****
>
> ** **
>
> Questions:****
>
> **1.       **Will I gain better performance if I put the rule
> differentiator condition “compareToPostThreshold($txn)==2” at the beginning
> of both rule 1 and 2?
>
One kind pf Rete optimization is based on evaluating common constraints
once, therefore: no.


> ****
>
> **2.       **I saw salaboy’s video claiming that to avoid using eval() in
> the rule. Do we have any alternative way to do that from a performance
> consideration
>
Constraints based on fields using == are best. Other things may result in
eval-like evaluations anyway. Most of the time, it isn't eval that causes
performance setbacks.

or I’d better collect/ prepare all the data before I send them into the
> session?
>
Not clear what you mean by this, but if you can provide attributes that
lend themselves to straightforward constraints it might be worthwhile
considering some up-front processing of facts.


> ****
>
> **3.       **What’s you guys’ naming convention for rule’s salience?
>
Not clear what you mean by that.

-W


> ****
>
> ** **
>
> PS: my Drools version is 5.2.0.****
>
> ** **
>
> Best regards****
>
> Abe****
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111226/9daba571/attachment.html 


More information about the rules-users mailing list