<br>&nbsp;&nbsp; Mike is correct again. What makes fact insertion faster or slower is the rules you have in your rulebase, because LHS patterns are evaluated at insert time. Although, there are several optimizations (and the Rete algorithm itself) that make this evaluation as light as possible. Usually, you should not feel noticeable delays in fact insertion, but if you have cross products in your rules, then you may have problems since they lead to combinatorial explosions.<br>
<br>&nbsp;&nbsp;&nbsp; So, take a look at your rules and ensure they are optimally written.<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">2009/2/6 Anstis, Michael (M.) <span dir="ltr">&lt;<a href="mailto:manstis1@ford.com">manstis1@ford.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;">Hello,<br>
<br>
Unless the Drools team have a &quot;secret optimisation&quot; *I think* there is<br>
no other way to insert large numbers of facts.<br>
<br>
Think about it; every fact you insert will need to be propagated through<br>
the RETE network in order for the correct rules to be activated.<br>
<br>
You could however optimise your rules to ensure the facts are processed<br>
as efficiently as possible. For example if you are interested in<br>
DataClasses where &quot;line&quot; is not empty you should have the RHS pattern<br>
that checks for this before other RHS patterns in rules. This should<br>
ensure the fact is not propagated through the network further than is<br>
really necessary. I believe Drools does this itself when the RETE<br>
network is built by have specialised &quot;Object&quot; nodes that filter out<br>
classes you have not consumed in RHS patters (so if you insert a Foo<br>
class into WM and your rules only use Bar classes the Foo class does not<br>
propagate further).<br>
<br>
With kind regards,<br>
<br>
Mike<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Senlin Liang<br>
Sent: 05 February 2009 20:06<br>
To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
Subject: [rules-users] one question about asserting facts<br>
<br>
Hi all,<br>
<br>
I am trying to assert (or insert) a large number of facts (or<br>
DataClass objects) in to a session, what i am doing right now is to<br>
insert them one by one as<br>
---------------------<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (line != null) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str = bufRead.readLine();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; session.insert(new DataClass(line, str));<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line = bufRead.readLine();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
---------------------<br>
<br>
My question: is there an efficient way to insert all facts at once, so<br>
that it takes less time?<br>
<br>
Thanks,<br>
Senlin<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>
<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> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>