Bugzilla – Attachment 135247 Details for
Bug 30824
Improve performance of BatchCommitItems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30824: Improve performance of BatchCommitItems
Bug-30824-Improve-performance-of-BatchCommitItems.patch (text/plain), 4.61 KB, created by
Nick Clemens (kidclamp)
on 2022-05-20 14:36:04 UTC
(
hide
)
Description:
Bug 30824: Improve performance of BatchCommitItems
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-05-20 14:36:04 UTC
Size:
4.61 KB
patch
obsolete
>From 282da260a2c468c64187054ed4967bf724612b54 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 20 May 2022 14:29:58 +0000 >Subject: [PATCH] Bug 30824: Improve performance of BatchCommitItems > >This makes two simple changes: >- Limit TransformMarcToKoha to the fields we need >- Pass forward the biblioitemnumber when adding items to a new biblionumber > >Profiling with NYTProf I saved ~8-9 seconds importing around 400 bibs/1000 items > >Reducing calls in item store to use a passed biblionumber was the largest gain. > >To test: >1 - Import some records and items >2 - Verify values etc., revert >3 - Apply patch >4 - Import again >5 - Verify values etc. same as before >--- > C4/ImportBatch.pm | 10 +++++----- > C4/Items.pm | 2 +- > 2 files changed, 6 insertions(+), 6 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 32b741fd95..e0dd051491 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -649,7 +649,7 @@ sub BatchCommitRecords { > ($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); > $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead > if ($item_result eq 'create_new' || $item_result eq 'replace') { >- my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); >+ my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, $biblioitemnumber); > $num_items_added += $bib_items_added; > $num_items_replaced += $bib_items_replaced; > $num_items_errored += $bib_items_errored; >@@ -735,12 +735,12 @@ sub BatchCommitRecords { > =head2 BatchCommitItems > > ($num_items_added, $num_items_errored) = >- BatchCommitItems($import_record_id, $biblionumber); >+ BatchCommitItems($import_record_id, $biblionumber, [$action, $biblioitemnumber]); > > =cut > > sub BatchCommitItems { >- my ( $import_record_id, $biblionumber, $action ) = @_; >+ my ( $import_record_id, $biblionumber, $action, $biblioitemnumber ) = @_; > > my $dbh = C4::Context->dbh; > >@@ -765,7 +765,7 @@ sub BatchCommitItems { > my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan' ); > $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield ); > >- my $item = TransformMarcToKoha({ record => $item_marc }); >+ my $item = TransformMarcToKoha({ record => $item_marc, kohafields => ['items.barcode','items.itemnumber'] }); > > my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} }); > my $duplicate_itemnumber = exists( $item->{'itemnumber'} ); >@@ -800,7 +800,7 @@ sub BatchCommitItems { > my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); > $item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); > >- my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); >+ my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, {biblioitemnumber => $biblioitemnumber} ); > if( $itemnumber ) { > $updsth->bind_param( 1, 'imported' ); > $updsth->bind_param( 2, $itemnumber ); >diff --git a/C4/Items.pm b/C4/Items.pm >index 03305eba33..d358675513 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -162,7 +162,6 @@ sub AddItemFromMarc { > # parse item hash from MARC > my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber); > my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" ); >- > my $localitemmarc = MARC::Record->new; > $localitemmarc->append_fields( $source_item_marc->field($itemtag) ); > >@@ -170,6 +169,7 @@ sub AddItemFromMarc { > my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); > $item_values->{more_subfields_xml} = _get_unlinked_subfields_xml($unlinked_item_subfields); > $item_values->{biblionumber} = $biblionumber; >+ $item_values->{biblioitemnumber} = $params->{biblioitemnumber}; > $item_values->{cn_source} = delete $item_values->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate > $item_values->{cn_sort} = delete $item_values->{'items.cn_sort'}; # Because of C4::Biblio::_disambiguate > my $item = Koha::Item->new( $item_values )->store({ skip_record_index => $params->{skip_record_index} }); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30824
:
135247
|
135307
|
135308
|
135369
|
135370