[rules-users] Order of columns and of constraints

Edson Tirelli tirelli at post.com
Thu May 31 08:39:03 EDT 2007


   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.

   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...

    []s
    Edson


2007/5/31, Anstis, Michael (M.) <manstis1 at ford.com>:
>
> Hi Dirk,
>
> I understand (but could be wrong!) that the ordering of patterns does
> influence the performance of the rules. I assume that the RETE network
> is created from top to bottom as the rules are parsed. Therefore more
> restrictive constraints at the start of a rule will be parsed first and
> hence be nearer the root of the RETE network consequentially optimising
> the identification of activations.
>
> I suspect the "Rules Team" will give a more scientific explanation ;-)
>
> With kind regards,
>
> Mike
>
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Dirk Bergstrom
> Sent: 31 May 2007 03:27
> To: Rules Users List
> Subject: [rules-users] Order of columns and of constraints
>
> Does the order of columns in the rule definition, and the order of
> constraints
> within a column matter?
>
> For a given rule, I know which test is most likely to fail, and
> (probably) which
> one is most "expensive" in terms of processing time (eg. 'someCollection
> contains $var' is more expensive than 'field == "literal"').  I'd like
> to put
> the fail-fast tests up front, and the expensive ones last.
>
> Does that actually work in Drools?  Can I "optimize" my rules by
> juggling the
> order of the columns and constraints?
>
> --
> Dirk Bergstrom               dirk at juniper.net
> _____________________________________________
> Juniper Networks Inc.,          Computer Geek
> Tel: 408.745.3182           Fax: 408.745.8905
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070531/bbda72e2/attachment.html 


More information about the rules-users mailing list