From 7fc75a2355e288f91424f0e38fff203ddedd618b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Jan 2018 10:07:03 -0500 Subject: [PATCH] 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 --- KCLS/authority-control/backstage/export-bibs.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 ) -- 2.11.0