https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39644 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- Sounds interesting. I'm not loving the code in "sub relationships_debt". Take a look at this section: 7a7a0a2474c Koha/Patron.pm (Kyle M Hall 2020-01-10 11:59:56 -0500 622) # I am a guarantor, I need to get all the guarantors of all my guarantees d659526b5ae Koha/Patron.pm (Koha Development Team 2025-01-27 13:21:28 +0100 623) @guarantors = map { $_->guarantor_relationships->guarantors->as_list } d659526b5ae Koha/Patron.pm (Koha Development Team 2025-01-27 13:21:28 +0100 624) $self->guarantee_relationships->guarantees->as_list; It looks like $self->guarantee_relationships->guarantees->as_list does 1 query to get all the guarantee relationships, fetches the guarantee IDs as a list, then fetches the borrowers using those IDs. So that's 2 queries that should get us 700 results. Probably not too bad. I don't recall the DBIC internals for as_list. I don't know if that fetches 1 by 1 or all at once. $_->guarantor_relationships->guarantors->as_list then does 1 query to get the guarantor relationships, which should be 1, deduplicates down to 1, and then fetches the borrower using that ID. 2 queries again. so (700x2) + (700x2) = 2800 DB queries. And if I'm not mistaken... @guarantors should now have 700 identical entries? We then loop through 700 of the same guarantors... but don't get duplicate charges because of the $seen variable. But then that means for 700 guarantors we're re-fetching the guarantee relationships in "my @guarantees = map { $_->guarantee } $guarantor->guarantee_relationships->as_list;" So now we have 700 guarantees. 700 guarantors times 700 guarantees = 490,000 iterations... although we're not re-counting the guarantees against because of the $seen variable. But yeah... that seems like a lot of work. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.