Repeatedly creating this ArrayList is bound to be O(n2). <br><br>Why do you want the Post facts as a List? There may be better ways for achieving your goal.<br><br>-W<br><br><br><div class="gmail_quote">On 13 February 2012 20:49, Shur, Bob <span dir="ltr">&lt;<a href="mailto:robert.shur@hp.com">robert.shur@hp.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a simple class Post { int id; ... }. I insert some number of them as facts and then call ksession.execute(facts);<br>

<br>
The whole drl file (except for package and import statements) is:<br>
<br>
rule &quot;collect&quot;<br>
when<br>
        $a : ArrayList(size &gt; 0) from collect(Post());<br>
then<br>
        System.out.println(&quot;Number of posts: &quot; + $a.size());<br>
        System.out.println(&quot;DONE&quot;);<br>
end<br>
<br>
The time it takes to run is n-squared in the number of posts. For 4000, 8000, 16000, 32000, 64000 posts the time is (in 1/10 seconds):<br>
<br>
4, 14, 56, 220, 852<br>
<br>
Is this expected? Is there a better way for me to do the collect?<br>
<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>
</blockquote></div><br>