From 6970735361eecb13327d61ac3437e99fbac128cd Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 3 Sep 2015 21:13:27 +0000 Subject: [PATCH] webstaff: improve performance of open-ils.search.authority.simple_heading.from_xml Searching authority.record_entry by comparing are.simple_heading with the results of authority.simple_normalize_heading() can result in bad query plans; if we calculate the results of that function first, we have a much better chance of hitting the index on simple_heading. Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../src/perlmods/lib/OpenILS/Application/Search/Authority.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm index d1f42d7225..a20dfb166d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm @@ -66,19 +66,26 @@ sub search_authority_by_simple_normalize_heading { my $marcxml = shift; my $controlset = shift; + my $norm_heading_query = { + from => [ 'authority.simple_normalize_heading' => $marcxml ] + }; + + my $e = new_editor(); + my $norm_heading = $e->json_query($norm_heading_query)->[0]->{'authority.simple_normalize_heading'}; + my $query = { select => { are => ['id'] }, from => 'are', where => { deleted => 'f', simple_heading => { - 'startwith' => [ 'authority.simple_normalize_heading' => $marcxml ] + 'startwith' => $norm_heading }, defined($controlset) ? ( control_set => $controlset ) : () } }; - $client->respond($_->{id}) for @{ new_editor()->json_query( $query ) }; + $client->respond($_->{id}) for @{ $e->json_query( $query ) }; $client->respond_complete; } __PACKAGE__->register_method( -- 2.11.0