From e9de82db81f674ba9b92a864a5cd17492dc1a01d Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 19 Feb 2013 11:39:40 -0500 Subject: [PATCH] QueryParser: Adjust visibility order Checking call number URIs last gives us a faster return on average based on finding copy information first. Signed-off-by: Thomas Berezansky Signed-off-by: Ben Shum --- .../Storage/Driver/Pg/QueryParser.pm | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index 6e80ba45e5..ff33c237f8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -866,16 +866,6 @@ sub toSQL { AND ( cbs.transcendant IS TRUE OR - EXISTS( - SELECT 1 FROM asset.call_number acn - JOIN asset.uri_call_number_map aucnm ON acn.id = aucnm.call_number - JOIN asset.uri uri ON aucnm.uri = uri.id - WHERE NOT acn.deleted AND uri.active AND acn.record = m.source AND acn.owning_lib IN ( - SELECT * FROM luri_org_list - ) - LIMIT 1 - ) - OR SQL if ($self->find_modifier('staff')) { $limit_where .= <<" SQL"; @@ -933,7 +923,19 @@ sub toSQL { ) SQL } - $limit_where .= " )"; + $limit_where .= <<" SQL"; + OR + EXISTS( + SELECT 1 FROM asset.call_number acn + JOIN asset.uri_call_number_map aucnm ON acn.id = aucnm.call_number + JOIN asset.uri uri ON aucnm.uri = uri.id + WHERE NOT acn.deleted AND uri.active AND acn.record = m.source AND acn.owning_lib IN ( + SELECT * FROM luri_org_list + ) + LIMIT 1 + ) + ) + SQL # For single records we want the record id # For metarecords we want NULL or the only record ID. -- 2.43.2