Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1685

Improve performance of rules using "or" in LHS

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Cannot Reproduce
    • Major
    • None
    • 6.5.0.Final
    • core engine, kie server
    • None
    • NEW
    • NEW

    Description

      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

      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
      

      Ruleset 2

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

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            rmorrise_jira Russell Morrisey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: