CIRCSTORE-643 Add index to request.itemId - #556
Merged
Conversation
… into CIRCSTORE-643
# Conflicts: # src/main/resources/templates/db_scripts/index_request_itemid_eq.sql
alexanderkurash
approved these changes
Mar 27, 2026
roman-barannyk
force-pushed
the
CIRCSTORE-643
branch
from
March 27, 2026 20:47
a7bab02 to
0618df6
Compare
roman-barannyk
force-pushed
the
CIRCSTORE-643
branch
from
March 27, 2026 21:38
fa7c823 to
15e2128
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Purpose
High database load and slow query volume were observed due to repeated lookups of circulation requests by itemId against mod_circulation_storage.request. The query pattern executed ~10 times/sec and was using a sequential scan, resulting in ~1.5s execution times per call. The activity correlated with mod-bulk-operations updating items. Creating a matching equality index on (jsonb->>'itemId') immediately resolved the performance issue by enabling index usage.
Expected Results:
Lookups of mod-circulation-storage requests by itemId should be index-supported and not require sequential scans on the request table, especially when invoked repeatedly by bulk operations.
Operations could align with request_itemid_idx
Actual Results:
Hypothesis: during item updates, mod-bulk-operations (directly or via downstream modules) performs a lookup for requests by itemId in mod-circulation-storage. The request lookup query was not able to use an existing index due to expression mismatch (request_itemid_idx ).
Workaround:
Applied once per tenant.
Created a matching index:
CREATE INDEX CONCURRENTLY IF NOT EXISTS request_itemid_eq_idx
ON mod_circulation_storage.request ((jsonb->>'itemId'));
Database logs showing slow query:
SELECT jsonb FROM mod_circulation_storage.request WHERE (jsonb->>?) = ?
2026-02-23 14:00:00:mod_circulation_storage@folio:LOG: duration: 1491.381 ms statement: SELECT jsonb FROM mod_circulation_storage.request WHERE (jsonb->>'itemId') = ''
Suspected Source:
10.23.36.233 - sidecar:8051 - [23/02/2026:13:56:05 UTC] "PUT /mod-inventory-storage/item-storage/items/ HTTP_1_1" 204 0 rt=0.021 uct="0.02" uht="" urt="" "" "" "" "278549/mod-bulk-operations;529418/inventory;170403/mod-inventory;985146/item-storage;656623/mod-inventory-storage"
Resolves: CIRCSTORE-643