[rules-users] Poor performance from a simple join

David Martin david.martin at mercedsystems.com
Mon Dec 19 12:03:01 EST 2011


No, Mark... You nailed it. My "guards" were reversed and my rules were no longer matching anything.

The change you suggest below seems to do the trick though... Putting the nested accessor first took a 90s process of 10k records down to 12s.

Phew!  I will double and triple check my work now, but thanks a million!  I would never have thought swapping the order could have such a huge impact on performance.

Dave

From: Mark Proctor <mproctor at codehaus.org<mailto:mproctor at codehaus.org>>
Reply-To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Date: Mon, 19 Dec 2011 16:59:25 +0000
To: <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Subject: Re: [rules-users] Poor performance from a simple join

On 19/12/2011 16:58, Mark Proctor wrote:
sorry I misread that, you've put the binding first, not using a nested accessor.

Currently you have
$call              : BINNING_INPUT()
$device_typeLookup : LU_DEVICE_TYPE( $call.device_type == device_type )

try rewriting it as:
$call              : BINNING_INPUT()
$device_typeLookup : LU_DEVICE_TYPE( device_type == $call.device_type )

I know edson was working on making such that the order no longer matters, I'm not sure what progress he made on that and he's away at the moment so can't answer. It may be that he's already done that work and it's correctly getting executed as an indexed constraint, or it might be rewritting to an eval. Hopefully edson can answer when he gets back.

Ass Mauricio suggests, maybe you can restrict the number of instances for BINNING_INPUT and LU_DEVICE_TYPE too.
ooops
s/Ass/As/

Mark




On 19/12/2011 16:51, Mark Proctor wrote:
Nested accessors are not currently indexed, because we cannot assure their immutability:
$call.device_type

If people changed indexed nested accessors, without correctly notifying the engine it would result in integrity problems.

If you have a large number of these, trying flattening the model, such as you would do in a database.

Mark
On 19/12/2011 16:23, David Martin wrote:
Folks:

My co-workers and I have been using Drools to great success, but we ran smack into a performance brick wall recently.

In the example below, both BINNING_INPUT and LU_DEVICE_TYPE have large numbers of associated facts in working memory (BINNING_INPUT has more than 8 million facts in working memory, LU_DEVICE_TYPE about 10k.)

LU_DEVICE_TYPE models a lookup table.

rule "Binning for Attribute: Device_type_desc"
  when
    $call :
      BINNING_INPUT()
    $device_typeLookup :
      LU_DEVICE_TYPE(
        $call.device_type == device_type
      )

  then
    $call.setDevice_type_desc($device_typeLookup.getDevice_type_desc());
end

It's a simple enough rule: join on the device_type field.  Unfortunately, this rule and a few others like it are taking FOREVER to insert.  Even when I cut the number of BINNING_INPUT facts in working memory down from 8M to 10k.

This feels like a basic Drools question.  But I can't seem to find any help from google.

Please advise!

Thanks in advance,

Dave Martin




_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________ rules-users mailing list rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org> https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111219/f885d074/attachment.html 


More information about the rules-users mailing list