View | Details | Raw Unified | Return to bug 19884
Collapse All | Expand All

(-)a/Koha/Item.pm (+8 lines)
Lines 235-240 sub current_holds { Link Here
235
    return Koha::Holds->_new_from_dbic($hold_rs);
235
    return Koha::Holds->_new_from_dbic($hold_rs);
236
}
236
}
237
237
238
sub unblessed {
239
    my ($self) = @_;
240
    my $itype = $self->effective_itemtype;
241
    my $h = $self->SUPER->unblessed;
242
    $h->{itype} = $itype;
243
    return $h;
244
}
245
238
=head3 type
246
=head3 type
239
247
240
=cut
248
=cut
(-)a/bench_dbic_vs_sql.pl (-1 / +45 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
use Modern::Perl;
3
use C4::Context;
4
use Koha::Database;
5
use t::lib::Mocks;
6
use Time::HiRes qw(gettimeofday tv_interval);
7
8
t::lib::Mocks::mock_preference('item-level_itypes', '1');
9
10
#BEGIN{$ENV{DBIC_TRACE}=1;};
11
12
my $biblionumbers = C4::Context->dbh->selectcol_arrayref(qq{SELECT biblionumber FROM biblio});
13
sub search_unblessed {
14
    my ($biblionumber) = @_;
15
    my $items = [];
16
    my $sth = C4::Context->dbh->prepare(qq{SELECT * FROM items WHERE biblionumber=?});
17
    $sth->execute($biblionumber);
18
    while (my $item = $sth->fetchrow_hashref) {
19
        push @{$items}, $item;
20
    }
21
    return wantarray ? @{$items} : $items;
22
}
23
sub search_dbic {
24
    my ($biblionumber) = @_;
25
    return [Koha::Database->new->schema->resultset('Item')->search(
26
            { biblionumber => $biblionumber },
27
            { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }
28
        )->all
29
    ];
30
}
31
32
my ($t0, $elapsed);
33
$t0 = [gettimeofday];
34
for my $biblionumber (@$biblionumbers ) {
35
    search_unblessed($biblionumber);
36
}
37
$elapsed = tv_interval ( $t0, [gettimeofday]);
38
print "plain SQL=${elapsed}s\n";
39
40
$t0 = [gettimeofday];
41
for my $biblionumber (@$biblionumbers ) {
42
    search_dbic($biblionumber);
43
}
44
$elapsed = tv_interval ( $t0, [gettimeofday]);
45
print "DBIC=${elapsed}s\n";

Return to bug 19884