Bugzilla – Attachment 70251 Details for
Bug 19884
Improve performance of GetItem
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19884: Add benchmark script to compare DBIC vs plain SQL
Bug-19884-Add-benchmark-script-to-compare-DBIC-vs-.patch (text/plain), 2.29 KB, created by
Jonathan Druart
on 2018-01-03 18:27:29 UTC
(
hide
)
Description:
Bug 19884: Add benchmark script to compare DBIC vs plain SQL
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-01-03 18:27:29 UTC
Size:
2.29 KB
patch
obsolete
>From 19a9db65d826da5c56acde0bd6c4ee7ffd0a271f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 3 Jan 2018 15:26:40 -0300 >Subject: [PATCH] Bug 19884: Add benchmark script to compare DBIC vs plain SQL > >--- > Koha/Item.pm | 8 ++++++++ > bench_dbic_vs_sql.pl | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 53 insertions(+) > create mode 100644 bench_dbic_vs_sql.pl > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index bea05f8317..73306f54a2 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -235,6 +235,14 @@ sub current_holds { > return Koha::Holds->_new_from_dbic($hold_rs); > } > >+sub unblessed { >+ my ($self) = @_; >+ my $itype = $self->effective_itemtype; >+ my $h = $self->SUPER->unblessed; >+ $h->{itype} = $itype; >+ return $h; >+} >+ > =head3 type > > =cut >diff --git a/bench_dbic_vs_sql.pl b/bench_dbic_vs_sql.pl >new file mode 100644 >index 0000000000..89eedfc2ad >--- /dev/null >+++ b/bench_dbic_vs_sql.pl >@@ -0,0 +1,45 @@ >+#!/usr/bin/perl >+use Modern::Perl; >+use C4::Context; >+use Koha::Database; >+use t::lib::Mocks; >+use Time::HiRes qw(gettimeofday tv_interval); >+ >+t::lib::Mocks::mock_preference('item-level_itypes', '1'); >+ >+#BEGIN{$ENV{DBIC_TRACE}=1;}; >+ >+my $biblionumbers = C4::Context->dbh->selectcol_arrayref(qq{SELECT biblionumber FROM biblio}); >+sub search_unblessed { >+ my ($biblionumber) = @_; >+ my $items = []; >+ my $sth = C4::Context->dbh->prepare(qq{SELECT * FROM items WHERE biblionumber=?}); >+ $sth->execute($biblionumber); >+ while (my $item = $sth->fetchrow_hashref) { >+ push @{$items}, $item; >+ } >+ return wantarray ? @{$items} : $items; >+} >+sub search_dbic { >+ my ($biblionumber) = @_; >+ return [Koha::Database->new->schema->resultset('Item')->search( >+ { biblionumber => $biblionumber }, >+ { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } >+ )->all >+ ]; >+} >+ >+my ($t0, $elapsed); >+$t0 = [gettimeofday]; >+for my $biblionumber (@$biblionumbers ) { >+ search_unblessed($biblionumber); >+} >+$elapsed = tv_interval ( $t0, [gettimeofday]); >+print "plain SQL=${elapsed}s\n"; >+ >+$t0 = [gettimeofday]; >+for my $biblionumber (@$biblionumbers ) { >+ search_dbic($biblionumber); >+} >+$elapsed = tv_interval ( $t0, [gettimeofday]); >+print "DBIC=${elapsed}s\n"; >-- >2.11.0
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 19884
:
70172
|
70182
|
70183
|
70184
|
70185
|
70247
|
70248
| 70251 |
70284
|
70285
|
70286
|
70606
|
82870
|
82871
|
82979
|
83111
|
83112
|
93949