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

Wolfgang Laun wolfgang.laun at gmail.com
Fri Oct 15 11:32:40 EDT 2010


For this sort of analysis one has to know
(1) whether one Member can be a member of a single company only, or whether
(s)he can be a member of more than one, too;
(2) (assuming it's N:1) whether is is possible to have a reference to the
company as a field in each Member object
(3) whether you can or cannot (for whatever reason) insert indovodual
Company objects as single facts into WM:
(4) whether you can or cannot (for whatever reason) insert individual Member
objects as single facts into WM:
(5) whether matching for an individual Member is possible by a unique
identification of that Member or whether it is only
possible in combination with the member's company (employee IDs are only
unique within a Company)

Best performance for rules where you have to search for a Member with
employeeId in a Company with name can be achieved
by s.th. like the rule shown below, where I assume that Member:Comp is N:1
and Member contains a reference to his/her Company:

rule
when
      LookFor( $comp : comp, $empId : empId )
      $c: Company( name == $comp )
      $m: Member( comp == $c, empId == $empId )
then ...

-W


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/020c0bd5/attachment.html 


More information about the rules-users mailing list