https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30169
--- Comment #3 from Martin Renvoize <[email protected]> --- I just wrote a benchmark for this: #!/usr/bin/env perl use strict; use warnings; use Benchmark qw/cmpthese timethese/; use Koha::Libraries; use Koha::Database; my $schema = Koha::Database->schema; cmpthese( -10, { kohaPrefetch => sub { my $checkouts = Koha::Checkouts->search({},{ prefetch => [ 'item', 'patron' ]}); while ( my $checkout = $checkouts->next ) { my $item_id = $checkout->item->itemnumber; my $patron_id = $checkout->patron->borrowernumber; } }, kohaJoin => sub { my $checkouts = Koha::Checkouts->search({}); while ( my $checkout = $checkouts->next ) { my $item_id = $checkout->item->itemnumber; my $patron_id = $checkout->patron->borrowernumber; } }, dbicPrefetch => sub { my $checkouts = $schema->resultset('Issue')->search({},{ prefetch => [ 'item', 'patron' ]}); while ( my $checkout = $checkouts->next ) { my $item_id = $checkout->item->itemnumber; my $patron_id = $checkout->patron->borrowernumber; } }, dbicJoin => sub { my $checkouts = $schema->resultset('Issue')->search({}); while ( my $checkout = $checkouts->next ) { my $item_id = $checkout->item->itemnumber; my $patron_id = $checkout->patron->borrowernumber; } } } ); It suggests prefetch is quicker in my findings.. but it's testing at a slightly different level.. I'm testing one prefetch over a large resultset.. you were testing lots of prefetches over a single result... I'll write a benchmark for that too.. I think it's object instantiation that's at fault here.. you are effectively instantiating the object for each iteration whereas I'm instantiating one object for all results. In short.. it depends on how we code as to whether adding prefetch is a good idea or not. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
