The Hold Ratio reporting source finds the common ancestor of the hold pickup library and each relevant copy's circ library using two calls to the ancestor.org_unit_ancestor_at_depth() function. This is the most direct way to determine if two org units share a specific common ancestor, but it is also very expensive.
This commit restructures the query by precalculating the set of descendants for each org unit, which allows for a faster test of whether the pickup and circ libs are both in the same descendant list. This is definitionally the same test as having a particular common ancestor, but can be performed MUCH faster.
As promised by Steve, a branch is available at: https:/ /git.evergreen- ils.org/ ?p=working/ Evergreen. git;a=shortlog; h=refs/ heads/user/ miker/lp- 2069062- faster- hold-ratio- source
From the commit message:
The Hold Ratio reporting source finds the common ancestor of the hold pickup library and each relevant copy's circ library using two calls to the ancestor. org_unit_ ancestor_ at_depth( ) function. This is the most direct way to determine if two org units share a specific common ancestor, but it is also very expensive.
This commit restructures the query by precalculating the set of descendants for each org unit, which allows for a faster test of whether the pickup and circ libs are both in the same descendant list. This is definitionally the same test as having a particular common ancestor, but can be performed MUCH faster.