[rules-users] Query about performance in using data as fact or using it as Global variable

Michael Anstis michael.anstis at gmail.com
Fri Oct 15 09:57:54 EDT 2010


I cannot tell from what you have posted; but without relating member to
company you run the risk of producing a Cartesian product of results which
would, no doubt, give you a performance problem.

rule "Cartesian product"
    when
        $c : Company()
        $m : Member()
    then
        //Joined all Companies to all Members. Ouch!
end

rule "Join 1"
    when
        $c : Company()
        $m : Member(company == $c)
    then
        //Nice
end

rule "Join 2"
    when
        $c : Company()
        $m : Member() from $c.members
    then
        //Nice
end

Rule "Join 2" should enable you to only insert Company's into working memory
too.


2010/10/15 Nikhil S. Kulkarni <Nikhil.Kulkarni at mastek.com>

>  Hi ,
>
>                 I am using drools 5.0 in application. I am facing
> performance issues. I am using drls, rule flows and rule templates.
>
>
>
> My scenario is as follows :-
>
>
>
> Consider there is list of 20 companies.
>
> There are about 20000 members in each company.
>
>
>
> Now I have several rules in which condition is for specific member and
> specific company.
>
>
>
> e.g.
>
>
>
> rule 1
>
>  when  comp : company
>
>                 and member : Members
>
> then
>
> ………
>
> End;
>
>
>
> So similarly I passed Member list and company list as fact. But it was time
> consuming process.
>
>
>
> So I have done one change.
>
>
>
> I kept only comp:company in when condition of rule as I explained above and
> declare member list as global .
>
>
>
> I created a function in rule in which I am iterating over member list and
> doing the same process.
>
>
>
> Now this is taking less time.
>
>
>
> Now my question is how efficient is this change.
>
>
>
> Though we say that when we write specific condition in rule then it will be
> fired only in that case.
>
> But when I use Agenda Event Listener class,
>
> I come to know one thing that it creates activation-created for all
> possible conditions then it will fire activation-Fired for specific
> condition
>
> And after that it will cancel all the activations.
>
>
>
> So as I reduced member level fact condition my time is reduced drastically
> and performance improved.
>
>
>
>
>
> So anybody can suggest me that whether I am on right track of improving
> time and performance or not ?
>
>
>
> Waiting for reply.
>
>
>
>
>
> *Thanks & Regards,*
>
> *Nikhil S. Kulkarni*
>
> * *
>
>
>
>
>
> MASTEK LTD.
> In the US, we're called MAJESCOMASTEK
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> _______________________________________________
> 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/20101015/71dba3e3/attachment.html 


More information about the rules-users mailing list