<br><br>   Hi,<br><br>   Ok, let me try to understand... in the following piece of code:<br><br>       CDEntryCache( (ValueCode.iterator.next == &quot;277.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br><br>   Is &quot;ValueCode&quot; a list? meaning iterator is actually creating an iterator for each of these conditions?<br>   Can we simplify this?<br>
<br>       CDEntryCache( valueCode[0] in ( &quot;277.1&quot;, &quot;277.2&quot;, &quot;277.3&quot;, &quot;277.4&quot;), valueCodeSystem[0] == &quot;2.16.840.1.113883.6.2&quot; )<br><br>    Assuming valueCode and valueCodeSystem are lists and by &quot;iterator.next&quot; you was getting the first element in each list, the above pattern is equivalent to that snippet from your rule. Assuming this is true, we could simplify a lot your rules, obviously improving the overall performance of the system.<br>
<br>    Just so you understand, every time you use &quot;or&quot;, behind the scenes the system calculates all possible logical branches and creates one &quot;sub-rule&quot; for each logical branch. With the amount of nested &quot;or&quot;s you used in your example rule, your kbase must be generating thousands of subrules.<br>
<br>    Let me know if the above works for you and we can proceed.<br><br>    Edson<br><br><br><div class="gmail_quote">2010/1/29 kashif10 <span dir="ltr">&lt;<a href="mailto:kash452@yahoo.com">kash452@yahoo.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Yes we have around 15-20K rules &amp; each rule have different set of conditions<br>
ANDed/ORed.<br>
Some rules are small have 10-15 conditions but some have more than 100<br>
conditions to be fullfilled to trigger the rule.<br>
<br>
The eval() function was taking time &amp; never loads the single rule.<br>
So today I change my logic &amp; start using java beans, &amp; insert the patient<br>
profile/data in CDEntryCache bean this will not fullfilled all of us<br>
condition, as we have some complex matching condition need to communicate<br>
with db e.g drug formualrtions etc but to give a try, I create the rule as<br>
follows:<br>
<br>
Following rule having some conditions which should be matched with<br>
WM(patient profile) to trigger the alert.<br>
<br>
#created on: Jan 29, 2009<br>
package my.rule;<br>
<br>
import java.util.List;<br>
import java.util.Vector;<br>
import java.rule.*;<br>
<br>
global java.util.Vector resultIds;<br>
<br>
rule &quot;kash3&quot;<br>
<br>
        when<br>
         #conditions<br>
<br>
         (<br>
<br>
<br>
         (<br>
<br>
        CDEntryCache( (valueName.iterator.next == &quot;Vibrio abc 1&quot;)||<br>
                     (ValueCode.iterator.next == &quot;243327001&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.96&quot;) )<br>
<br>
        or<br>
<br>
        CDEntryCache( (valueName.iterator.next == &quot;Vibrio abc splendidus 2&quot;)||<br>
                     (ValueCode.iterator.next == &quot;243327002&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.96&quot;) )<br>
<br>
        or<br>
        CDEntryCache( (valueName.iterator.next == &quot;Vibrio abc splendidus 3&quot;)||<br>
                     (ValueCode.iterator.next == &quot;243327003&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.96&quot;) )<br>
<br>
        or<br>
        CDEntryCache( (valueName.iterator.next == &quot;Vibrio abc splendidus 4&quot;)||<br>
                     (ValueCode.iterator.next == &quot;243327004&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.96&quot;) )<br>
<br>
<br>
         )<br>
        and<br>
<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
        and<br>
<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;377.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;377.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;377.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;377.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
                        and<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;477.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;477.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;477.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;477.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
<br>
        and<br>
<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;577.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;577.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;577.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;577.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
<br>
        and<br>
<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;677.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;677.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;677.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;477.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
<br>
        and<br>
<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;877.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;877.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;877.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;877.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
<br>
        and<br>
<br>
<br>
         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;977.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;977.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;977.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;977.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
<br>
        and<br>
<br>
                         (<br>
<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;777.1&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;777.2&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;777.3&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
        or<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;777.4&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
         )<br>
<br>
<br>
        and<br>
         (<br>
<br>
<br>
        CDEntryCache( (valueName.iterator.next == &quot;Vibrio splendidus biogroup I&quot;)||<br>
                     (ValueCode.iterator.next == &quot;115054009&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.96&quot;) )<br>
<br>
         )<br>
<br>
        and<br>
        CDEntryCache( (ValueCode.iterator.next == &quot;277.6&quot; &amp;&amp;<br>
ValueCodeSystem.iterator.next == &quot;2.16.840.1.113883.6.2&quot;) )<br>
<br>
         )<br>
<br>
<br>
<br>
        then<br>
                #actions<br>
                System.out.println(&quot;*********** RULE TRIGGERS ************&quot;);<br>
                resultIds.add(&quot;kash3&quot;);<br>
<br>
end<br>
<br>
<br>
The above rule have 36 conditions of CDEntryCache 3-4 conditions ORed with<br>
each other then ANDed with another similar type of condition block. And it<br>
takes so much memory of the system on kbase.addKnowledgePackages<br>
the rule file is around 6kb but the knowdge package taking so much memory.<br>
from 40Mb it goes to 401Mb<br>
<br>
after  kbuilder.getKnowledgePackages()<br>
Total Memory: 799145984<br>
        Used: 42047936<br>
        Free: 757098048<br>
Percent Used: 5.261608872703789<br>
Percent Free: 94.73839112729621<br>
Time: 2010-01-29 15:55:53.419<br>
<br>
after  kbase.addKnowledgePackages(pkgs)<br>
Total Memory: 799145984<br>
        Used: 420606424<br>
        Free: 378539560<br>
Percent Used: 52.63198870057764<br>
Percent Free: 47.368011299422356<br>
Time: 2010-01-29 15:56:09.999<br>
<br>
<br>
<br>
Thanks.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n3.nabble.com/Weblogic-rules-to-Drools-rules-tp126265p144134.html" target="_blank">http://n3.nabble.com/Weblogic-rules-to-Drools-rules-tp126265p144134.html</a><br>
</font><div><div></div><div class="h5">Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>