Skip to content

CIRCSTORE-643 Add index to request.itemId - #556

Merged
roman-barannyk merged 18 commits into
masterfrom
CIRCSTORE-643
Mar 28, 2026
Merged

CIRCSTORE-643 Add index to request.itemId#556
roman-barannyk merged 18 commits into
masterfrom
CIRCSTORE-643

Conversation

@roman-barannyk

@roman-barannyk roman-barannyk commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

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

image

@sonarqubecloud

Copy link
Copy Markdown

@roman-barannyk
roman-barannyk merged commit f244a89 into master Mar 28, 2026
18 checks passed
@roman-barannyk
roman-barannyk deleted the CIRCSTORE-643 branch March 28, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants