From: miker Date: Fri, 16 Jul 2010 02:37:24 +0000 (+0000) Subject: use a left join instead of -not-exists for anti-join -- much faster for large nullabl... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b0be87b5cb7189280c253dc24b545876c6647813;p=evergreen%2Fbjwebb.git use a left join instead of -not-exists for anti-join -- much faster for large nullable-side sets in this case git-svn-id: svn://svn.open-ils.org/ILS/trunk@16953 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm index b12e897b4..6a916c079 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -453,16 +453,16 @@ sub create_batch_events { push @{ $$filter{'-and'} }, $f; } - push @{ $filter->{'-and'} }, { - '-not-exists' => { - from => 'atev', - where => { - event_def => $def->id, - target => { '=' => { '+' . $hook_hash{$def->hook}->core_type => $class->Identity } }, - ($active ? (state => 'pending') : ()) - } + my $join = { 'join' => { + atev => { + field => 'target', + fkey => $class->Identity, + type => 'left', + filter => { event_def => $def->id } } - }; + }}; + + push @{ $filter->{'-and'} }, { '+atev' => { id => undef } }; if ($def->usr_field && $def->opt_in_setting) { push @{ $filter->{'-and'} }, { @@ -487,7 +487,7 @@ sub create_batch_events { $logger->info("trigger: create_batch_events() collecting object IDs for def=$def_id / hook=$hook"); - my $object_ids = $editor->$method( $filter, {idlist => 1, timeout => 10800} ); + my $object_ids = $editor->$method( [$filter, $join], {idlist => 1, timeout => 10800} ); if($object_ids) { $logger->info("trigger: create_batch_events() fetched ".scalar(@$object_ids)." object IDs for def=$def_id / hook=$hook");