Bugzilla – Attachment 53875 Details for
Bug 17009
Duplicating frameworks is unnecessary slow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17009: Speed up the framework duplication
Bug-17009-Speed-up-the-framework-duplication.patch (text/plain), 3.17 KB, created by
Jonathan Druart
on 2016-08-02 08:49:45 UTC
(
hide
)
Description:
Bug 17009: Speed up the framework duplication
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-08-02 08:49:45 UTC
Size:
3.17 KB
patch
obsolete
>From b754ef0f45e4438e1a9ead16800b73d7b7927764 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 1 Aug 2016 13:46:49 +0100 >Subject: [PATCH] Bug 17009: Speed up the framework duplication > >To duplicate frameworks, the code retrieve all the subfields, then >execute 1 insert per subfield. >It's unnecessary slow, we can use the DBMS to do it. > >Test plan: >Create a new framework and duplicate the structure of another framework. >--- > admin/marctagstructure.pl | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > >diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl >index 0f27ac0..2b4f2a1 100755 >--- a/admin/marctagstructure.pl >+++ b/admin/marctagstructure.pl >@@ -344,18 +344,11 @@ sub StringSearch { > sub duplicate_framework { > my ($newframeworkcode,$oldframeworkcode) = @_; > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where frameworkcode=?"); >- $sth->execute($oldframeworkcode); >- my $sth_insert = $dbh->prepare("insert into marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)"); >- while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) { >- $sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode); >- } >+ $dbh->do(q|INSERT INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) >+ SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value, ? from marc_tag_structure where frameworkcode=?|, undef, $newframeworkcode, $oldframeworkcode ); > >- $sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=?"); >- $sth->execute($oldframeworkcode); >- $sth_insert = $dbh->prepare("insert into marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >- while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso,$hidden) = $sth->fetchrow) { >- $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso, $hidden); >- } >+ $dbh->do(q|INSERT INTO marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden) >+ SELECT ?,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=? >+ |, undef, $newframeworkcode, $oldframeworkcode ); > } > >-- >2.8.1
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 17009
:
53835
|
53875
|
54132
|
54398