Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- explain analyze SELECT "ahopl".capture_time, "ahopl".current_copy, "ahopl".email_notify, "ahopl".expire_time, "ahopl".fulfillment_lib, "ahopl".fulfillment_staff, "ahopl".fulfillment_time, "ahopl".hold_type, "ahopl".holdable_formats, "ahopl".id, "ahopl".phone_notify, "ahopl".sms_notify, "ahopl".sms_carrier, "ahopl".pickup_lib, "ahopl".prev_check_time, "ahopl".request_lib, "ahopl".request_time, "ahopl".requestor, "ahopl".selection_depth, "ahopl".selection_ou, "ahopl".target, "ahopl".usr, "ahopl".cancel_time, "ahopl".frozen, "ahopl".thaw_date, "ahopl".shelf_time, "ahopl".cancel_cause, "ahopl".cancel_note, "ahopl".cut_in_line, "ahopl".mint_condition, "ahopl".shelf_expire_time, "ahopl".current_shelf_lib, "ahopl".copy_location_order_position, "ahopl".usr_first_given_name, "ahopl".usr_second_given_name, "ahopl".usr_family_name, "ahopl".usr_prefix, "ahopl".usr_suffix, "ahopl".usr_alias_or_first_given_name, "ahopl".usr_display_name, "ahopl".usr_alias_or_display_name, "ahopl".usr_alias, "ahopl".call_number_label, "ahopl".issuance_label, "ahopl".is_staff_hold, "ahopl".potential_copies, "ahopl".behind_desk FROM (
- SELECT
- ahr.*,
- COALESCE(acplo.position, acpl_ordered.fallback_position) AS
- copy_location_order_position,
- CASE WHEN au.alias IS NOT NULL THEN
- au.alias
- ELSE
- au.first_given_name
- END AS usr_alias_or_first_given_name,
- au.first_given_name AS usr_first_given_name,
- au.second_given_name AS usr_second_given_name,
- au.family_name AS usr_family_name,
- au.prefix AS usr_prefix,
- au.suffix AS usr_suffix,
- au.alias AS usr_alias,
- CASE WHEN au.alias IS NOT NULL THEN
- au.alias
- ELSE
- REGEXP_REPLACE(ARRAY_TO_STRING(ARRAY[
- COALESCE(au.family_name, ''),
- COALESCE(au.suffix, ''),
- ', ',
- COALESCE(au.prefix, ''),
- COALESCE(au.first_given_name, ''),
- COALESCE(au.second_given_name, '')
- ], ' '), E'\\s+,', ',')
- END AS usr_alias_or_display_name,
- REGEXP_REPLACE(ARRAY_TO_STRING(ARRAY[
- COALESCE(au.family_name, ''),
- COALESCE(au.suffix, ''),
- ', ',
- COALESCE(au.prefix, ''),
- COALESCE(au.first_given_name, ''),
- COALESCE(au.second_given_name, '')
- ], ' '), E'\\s+,', ',') AS usr_display_name,
- TRIM(acnp.label || ' ' || acn.label || ' ' || acns.label)
- AS call_number_label,
- siss.label AS issuance_label,
- (ahr.usr <> ahr.requestor) AS is_staff_hold,
- ahcm_1.copy_count AS potential_copies
- FROM action.hold_request ahr
- JOIN asset.copy acp ON (acp.id = ahr.current_copy)
- JOIN asset.call_number acn ON (acp.call_number = acn.id)
- JOIN asset.call_number_prefix acnp ON (acn.prefix = acnp.id)
- JOIN asset.call_number_suffix acns ON (acn.suffix = acns.id)
- JOIN actor.usr au ON (au.id = ahr.usr)
- JOIN (
- SELECT *, (ROW_NUMBER() OVER (ORDER BY name) + 1000000) AS fallback_position
- FROM asset.copy_location
- ) acpl_ordered ON (acpl_ordered.id = acp.location)
- LEFT JOIN actor.usr_standing_penalty ausp
- ON (au.id = ausp.usr AND (ausp.stop_date IS NULL OR ausp.stop_date > NOW()))
- LEFT JOIN config.standing_penalty csp
- ON (
- csp.id = ausp.standing_penalty AND
- csp.block_list LIKE '%CAPTURE%' AND (
- (csp.org_depth IS NULL AND ahr.pickup_lib = ausp.org_unit) OR
- (csp.org_depth IS NOT NULL AND ahr.pickup_lib IN (
- SELECT id FROM actor.org_unit_descendants(ausp.org_unit, csp.org_depth))
- )
- )
- )
- JOIN (
- SELECT COUNT(target_copy) AS copy_count, hold
- FROM action.hold_copy_map
- GROUP BY 2
- ) ahcm_1 ON (ahcm_1.hold = ahr.id)
- LEFT JOIN serial.issuance siss
- ON (ahr.hold_type = 'I' AND siss.id = ahr.target)
- LEFT JOIN asset.copy_location_order acplo
- ON (acp.location = acplo.location AND
- acp.circ_lib = acplo.org)
- WHERE
- ahr.capture_time IS NULL AND
- ahr.cancel_time IS NULL AND
- csp.id IS NULL AND
- (ahr.expire_time is NULL OR ahr.expire_time > NOW()) AND
- acp.status IN (0,7)
- ) AS "ahopl" WHERE "ahopl".id = '4489817';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement