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(a)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(a)lists.jboss.org
[mailto:rules-users-bounces@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(a)juniper.net
_____________________________________________
Juniper Networks Inc., Computer Geek
Tel: 408.745.3182 Fax: 408.745.8905
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)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