[Koha-bugs] [Bug 13645] DBIx connection needs to be cached

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Feb 4 15:48:41 CET 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13645

--- Comment #8 from Jacek Ablewicz <abl at biblos.pk.edu.pl> ---
(In reply to Jonathan Druart from comment #7)

> I quickly implemented Koha::Acquisition::Bookseller using Koha::Object (see
> bug 13019) and tested with
> 
>   use Modern::Perl;
>   use Koha::Acquisition::Booksellers;
>   my $booksellers = Koha::Acquisition::Booksellers->search;
>   while ( my $b = $booksellers->next ) {
>       say $b->name;
>   }
> 
> perl benchmark_bookseller.pl  1.00s user 0.03s system 96% cpu 1.072 total

Speed-wise, I'm getting pretty much the same results with the following
quick&dirty mod:

--- a/Koha/Acquisition/Bookseller.pm
+++ b/Koha/Acquisition/Bookseller.pm
@@ -46,13 +46,12 @@ sub search {
     }
     my $rs = $schema->resultset('Aqbookseller')->search(
         $search_params,
-        { order_by => 'name' }
+        { order_by => 'name' }, { result_class =>
'DBIx::Class::ResultClass::HashRefInflator' }
     );

     my @booksellers;
     while ( my $b = $rs->next ) {
-        my $t = Koha::Acquisition::Bookseller->fetch({ id => $b->id });
-        push @booksellers, $t;
+        push @booksellers, $b;
     }
     return @booksellers;
 }

With it, booksellers.pl loading times are 0.96 sec / 1.82 sec / 10.3 sec for
170 / 1700 / 17000 booksellers in the database.
Whenever DBIx object is cached or not cached doesn't seem to matter much with
such mod - I guess because there would be just one DBIx schema/connection
object created in this case anyway?

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list