From b6b569b20aef7c293f1f6bdbb7b56276132f9aaf Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 22 Jul 2022 14:47:36 +0000 Subject: [PATCH] Bug 31222: Reduce query size for batchMod The object search is currently: Koha::Items->search({ barcode => \@contentlist } Which generate code like: barcode = 1 OR barcode = 2 OR barcode = 3 .... This can get quite large We can reduce the query size by using -in: Koha::Items->search({ barcode => { -in => \@contentlist } } Which generates code like: barcode in ( 1, 2, 3 ) To test: 1 - Apply patch 2 - Perform batch modifications 3 - Confirm nothing has changed Signed-off-by: Rachael Laritz Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 7343e404b7b486c52a150613f308e452f4f5da05) Signed-off-by: Lucas Gass (cherry picked from commit dd5fcd9de3b6c9201c20e3b279f25649d1e7fac0) Signed-off-by: Arthur Suzuki --- tools/batchMod.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 9646020d6f..6867b66126 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -218,13 +218,13 @@ if ($op eq "show"){ @contentlist = grep /\S/, ( map { split /[$split_chars]/ } @contentlist ); @contentlist = uniq @contentlist; # Note: adding lc for case insensitivity - my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@contentlist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; + my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => { -in => \@contentlist } }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @contentlist; @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @contentlist; } elsif ( $filecontent eq 'itemid_file') { @contentlist = uniq @contentlist; - my %itemdata = map { $_->{itemnumber} => 1 } @{ Koha::Items->search({ itemnumber => \@contentlist }, { columns => [ 'itemnumber' ] } )->unblessed }; + my %itemdata = map { $_->{itemnumber} => 1 } @{ Koha::Items->search({ itemnumber => { -in => \@contentlist } }, { columns => [ 'itemnumber' ] } )->unblessed }; @itemnumbers = grep { exists $itemdata{$_} } @contentlist; @notfounditemnumbers = grep { !exists $itemdata{$_} } @contentlist; } @@ -240,7 +240,7 @@ if ($op eq "show"){ @barcodelist = map { barcodedecode( $_ ) } @barcodelist; # Note: adding lc for case insensitivity - my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; + my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => { -in => \@barcodelist } }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed }; @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist; @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @barcodelist; } -- 2.39.5