From: Bill Erickson Date: Wed, 17 Jan 2018 15:07:03 +0000 (-0500) Subject: Backstage quarterly export query improvement X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7fc75a2355e288f91424f0e38fff203ddedd618b;p=working%2FEvergreen.git Backstage quarterly export query improvement Tweak the holdings-exists part of the query to use a JOIN instead of an IN check. Though the exact cause of the recent slow-down is unknown, this change allows the query to complete in minutes instead of hours. Signed-off-by: Bill Erickson --- diff --git a/KCLS/authority-control/backstage/export-bibs.pl b/KCLS/authority-control/backstage/export-bibs.pl index dee53a9a46..0799a9c856 100755 --- a/KCLS/authority-control/backstage/export-bibs.pl +++ b/KCLS/authority-control/backstage/export-bibs.pl @@ -133,13 +133,13 @@ WITH viable_records AS ( ) WHERE vr.cataloging_date IS NOT NULL AND EXISTS ( -- bib has at least one non-deleted copy - SELECT acp.id + SELECT acp.id FROM asset.copy acp - WHERE call_number IN ( - SELECT id FROM asset.call_number - WHERE record = vr.id AND NOT deleted - ) - AND NOT deleted + JOIN asset.call_number acn ON (acn.id = acp.call_number) + WHERE + acn.record = vr.id + AND NOT acn.deleted + AND NOT acp.deleted LIMIT 1 )