[rules-users] named consequences for an or...
pmander
paul.s.mander at gmail.com
Tue Jan 21 08:20:32 EST 2014
laune wrote
> On 20/01/2014, pmander <
> paul.s.mander@
> > wrote:
>> I could do this:
>>
>> when
>> $t : Transaction((org == "us") || (expensive() == "111"))
>> then
>> insert(new Record($t, 1));
>> end
>>
>
> Yes, that takes care of the unwanted duplication.
>
>> If org is indeed equal to "us" is it guaranteed that expensive() doesn't
>> get
>> executed?
>
> You can test this quite easily: add a print to expensive().
>
> -W
I quick related question regarding performance. I now have
rule "3"
when
$t : Transaction(
(
(
fieldFor("SALES_ORG")=="SO10167" &&
fieldFor("CHANNEL")=="A" &&
fieldFor("ONLINE_IND")=="N" &&
colMatch(rulesMap,3,2000,baseData,"PRODUCT",0)
) ||
(
fieldFor("CHANNEL")=="A" &&
fieldFor("ONLINE_IND")=="N" &&
fieldFor("ACCOUNT")
in("A11329","A11330","A11331","A11332","A11333","A11334","A11335","A11336")
&&
colMatch(rulesMap,3,2000,baseData,"PRODUCT",0)
)
)
)
then
do something
end
instead of
rule "3"
when
$t : (
Transaction(
fieldFor("CHANNEL")=="A",
fieldFor("ONLINE_IND")=="N",
fieldFor("SALES_ORG")=="SO10167",
colMatch(rulesMap,3,1370,baseData,"PRODUCT",0))
or
Transaction(
fieldFor("CHANNEL")=="A",
fieldFor("ONLINE_IND")=="N",
fieldFor("ACCOUNT")
in("A11329","A11330","A11331","A11332","A11333","A11334","A11335","A11336"),
colMatch(rulesMap,3,2000,baseData,"PRODUCT",0)
)
then
do something
end
I would have thought that the first was slight better performance wise as
the second produces twice as many matches which I need to filter out but
putting 20,000 Transactions through this (2400 rules) takes 51 seconds for
option 2 and 200 seconds for option 1.
If I just have the first half of the rule:
$t : (
Transaction(
fieldFor("CHANNEL")=="A",
fieldFor("ONLINE_IND")=="N",
fieldFor("SALES_ORG")=="SO10167",
colMatch(rulesMap,3,1370,baseData,"PRODUCT",0))
then
do something
end
then the performance is 10 seconds. The extra time being taken up with all
those other "or" mis-matches.
--
View this message in context: http://drools.46999.n3.nabble.com/named-consequences-for-an-or-tp4027775p4027792.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list