[rules-users] Performance of collect seems to be n-squared

Shur, Bob robert.shur at hp.com
Mon Feb 13 14:49:30 EST 2012


I have a simple class Post { int id; ... }. I insert some number of them as facts and then call ksession.execute(facts);

The whole drl file (except for package and import statements) is:

rule "collect"
when
	$a : ArrayList(size > 0) from collect(Post());
then
	System.out.println("Number of posts: " + $a.size());
	System.out.println("DONE");
end

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):

4, 14, 56, 220, 852

Is this expected? Is there a better way for me to do the collect?





More information about the rules-users mailing list