[jboss-jira] [JBoss JIRA] (DROOLS-1685) Improve performance of rules using "or" in LHS
Russell Morrisey (JIRA)
issues at jboss.org
Mon Jul 31 10:47:00 EDT 2017
Russell Morrisey created DROOLS-1685:
----------------------------------------
Summary: Improve performance of rules using "or" in LHS
Key: DROOLS-1685
URL: https://issues.jboss.org/browse/DROOLS-1685
Project: Drools
Issue Type: Enhancement
Components: core engine, kie server
Affects Versions: 6.5.0.Final
Reporter: Russell Morrisey
Assignee: Mario Fusco
The following two rulesets produce the same output, but their performance differs dramatically.
My understanding is that the two rulesets should be equivalent to one another. It seems like the 'or' operation must be handled inefficiently by the engine. Is there anything that can be improved the engine's performance in this case?
Ruleset #1 takes ~3 seconds to execute on my local machine (for a dataset with 3 entities, 1 service ordered each). Ruleset #2 runs in ~200 ms.
*Ruleset 1*
{code:java}
rule "Rule183"
dialect "mvel"
when
$entity : Entity( )
( $service : ServiceOrdered( serviceId == "FORM" , entity == $entity , entity.entityTypeId in ( 291262, 291275, 291277 ) ) or $service : ServiceOrdered( serviceId == "DISSO" , entity == $entity , entity.entityTypeId in ( 291262 ) , stateId == 290864 ) )
$r1 : QuestionDefinition( id == 590 )
then
Question fact0 = new Question();
fact0.setQuestionDefinition( $r1 );
fact0.setEntity( $entity );
insert( fact0 );
end
{code}
*Ruleset 2*
{code:java}
rule "Rule183"
dialect "mvel"
when
$entity : Entity( )
$service : ServiceOrdered( serviceId == "FORM" , entity == $entity , entity.entityTypeId in ( 291262, 291275, 291277 ) )
$r1 : QuestionDefinition( id == 590 )
then
Question fact0 = new Question();
fact0.setQuestionDefinition( $r1 );
fact0.setEntity( $entity );
insert( fact0 );
end
{code}
{code}
rule "Rule183-2"
dialect "mvel"
when
$entity : Entity( )
$service : ServiceOrdered( serviceId == "DISSO" , entity == $entity , entity.entityTypeId == 291262 , stateId == 290864 )
$r1 : QuestionDefinition( id == 590 )
then
Question fact0 = new Question();
fact0.setQuestionDefinition( $r1 );
fact0.setEntity( $entity );
insert( fact0 );
end
{code}
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list