<br> Michael got it right. Always try to write your most restrictive Patterns at the top of the rule, reducing partial matches in the network and improving efficiency. When talking about constraints inside a pattern, the same rule apply, but in this case, the engine does some transformations bringing indexable constraints to the front. But it still is good to have the most restrictive first and less restrictives later.
<br><br> Rules are like SQL queries: there are several ways to write one, but usually the difference of performance for a good written query compared to a badly written one is huge...<br><br> []s<br> Edson<br><br>
<br><div><span class="gmail_quote">2007/5/31, Anstis, Michael (M.) <<a href="mailto:manstis1@ford.com">manstis1@ford.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Dirk,<br><br>I understand (but could be wrong!) that the ordering of patterns does<br>influence the performance of the rules. I assume that the RETE network<br>is created from top to bottom as the rules are parsed. Therefore more
<br>restrictive constraints at the start of a rule will be parsed first and<br>hence be nearer the root of the RETE network consequentially optimising<br>the identification of activations.<br><br>I suspect the "Rules Team" will give a more scientific explanation ;-)
<br><br>With kind regards,<br><br>Mike<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 Dirk Bergstrom<br>Sent: 31 May 2007 03:27<br>To: Rules Users List<br>Subject: [rules-users] Order of columns and of constraints<br><br>Does the order of columns in the rule definition, and the order of
<br>constraints<br>within a column matter?<br><br>For a given rule, I know which test is most likely to fail, and<br>(probably) which<br>one is most "expensive" in terms of processing time (eg. 'someCollection
<br>contains $var' is more expensive than 'field == "literal"'). I'd like<br>to put<br>the fail-fast tests up front, and the expensive ones last.<br><br>Does that actually work in Drools? Can I "optimize" my rules by
<br>juggling the<br>order of the columns and constraints?<br><br>--<br>Dirk Bergstrom <a href="mailto:dirk@juniper.net">dirk@juniper.net</a><br>_____________________________________________<br>Juniper Networks Inc., Computer Geek
<br>Tel: 408.745.3182 Fax: 408.745.8905<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">
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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer
<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>