https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42835 --- Comment #5 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Created attachment 200316 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200316&action=edit Bug 42835: OPAC performance: Batch item visibility check to reduce N+1 DB queries Before the main result loop, pre-scan all MARC records for the current page to collect every itemnumber in one pass. Run a single batched filter_by_visible_in_opac call and store the result in a hash. The inner item loop then does a plain hash lookup instead of one Koha::Items DB query per item, reducing N queries to 1 per page load. Falls back to the per-item path if no itemnumbers are found in the pre-scan. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.