Bug 7276 : member entry Performance improvement
Before this patch : 9619 borrowers added in 31 Minutes, After : 68 seconds. This adds Hashref to table structure in C4::SQLHelper to speed up bulk edits. Signed-off-by: Stéphane Delaune <stephane.delaune@biblibre.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
b08ccda99d
commit
6c38cc23d9
1 changed files with 33 additions and 6 deletions
|
@ -27,6 +27,22 @@ use C4::Debug;
|
|||
require Exporter;
|
||||
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
|
||||
|
||||
eval {
|
||||
my $servers = C4::Context->config('memcached_servers');
|
||||
if ($servers) {
|
||||
require Memoize::Memcached;
|
||||
import Memoize::Memcached qw(memoize_memcached);
|
||||
|
||||
my $memcached = {
|
||||
servers => [$servers],
|
||||
key_prefix => C4::Context->config('memcached_namespace') || 'koha',
|
||||
};
|
||||
|
||||
memoize_memcached( '_get_columns', memcached => $memcached, expire_time => 600000 ); #cache for 10 minutes
|
||||
memoize_memcached( 'GetPrimaryKeys', memcached => $memcached, expire_time => 600000 ); #cache for 10 minutes
|
||||
}
|
||||
};
|
||||
|
||||
BEGIN {
|
||||
# set the version for version checking
|
||||
$VERSION = 0.5;
|
||||
|
@ -43,6 +59,9 @@ BEGIN {
|
|||
);
|
||||
}
|
||||
|
||||
my $tablename;
|
||||
my $hashref;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
C4::SQLHelper - Perl Module containing convenience functions for SQL Handling
|
||||
|
@ -247,16 +266,24 @@ With
|
|||
=cut
|
||||
|
||||
sub _get_columns($) {
|
||||
my ($tablename)=@_;
|
||||
my $dbh=C4::Context->dbh;
|
||||
my $sth=$dbh->prepare_cached(qq{SHOW COLUMNS FROM $tablename });
|
||||
$sth->execute;
|
||||
my $columns= $sth->fetchall_hashref(qw(Field));
|
||||
my ($tablename) = @_;
|
||||
unless ( exists( $hashref->{$tablename} ) ) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth = $dbh->prepare_cached(qq{SHOW COLUMNS FROM $tablename });
|
||||
$sth->execute;
|
||||
my $columns = $sth->fetchall_hashref(qw(Field));
|
||||
$hashref->{$tablename} = $columns;
|
||||
}
|
||||
return $hashref->{$tablename};
|
||||
}
|
||||
|
||||
=head2 _filter_columns
|
||||
|
||||
_filter_columns($tablename,$research, $filtercolumns)
|
||||
=over 4
|
||||
|
||||
_filter_columns($tablename,$research, $filtercolumns)
|
||||
|
||||
=back
|
||||
|
||||
Given
|
||||
- a tablename
|
||||
|
|
Loading…
Reference in a new issue