Read all checksums from the last session and store them in a hash.
This should speed up retrieving checksums considerably.
This commit is contained in:
parent
069d20a488
commit
cc770cdf9e
|
@ -443,14 +443,7 @@ sub db_record_version {
|
|||
$self->{times}{db_record_version_insert_files} += $t2 - $t1;
|
||||
if ($f->{t} eq 'f' && !defined($f->{checksum})) {
|
||||
# this must be a link to the previous version
|
||||
my $db_pv = $self->{dbh}->selectall_arrayref(
|
||||
"select * from versions2 v, instances i
|
||||
where file=? and session=? and v.id = i.version",
|
||||
{ Slice => {} },
|
||||
$db_f->[0]{id},
|
||||
$self->{last_backup_id}
|
||||
);
|
||||
$f->{checksum} = $db_pv->[0]{checksum};
|
||||
$f->{checksum} = $self->get_checksum($db_f->[0]{id});
|
||||
}
|
||||
my $t2a = gettimeofday();
|
||||
$self->{times}{db_record_version_versions2_get_checksum} += $t2a - $t2;
|
||||
|
@ -525,6 +518,23 @@ sub db_record_version {
|
|||
$self->{times}{db_record_version} += $t4 - $t0;
|
||||
}
|
||||
|
||||
sub get_checksum {
|
||||
my ($self, $file) = @_;
|
||||
if ($self->{caches}{file_checksums}{$self->{last_backup_id}}) {
|
||||
return $self->{caches}{file_checksums}{$self->{last_backup_id}}{$file};
|
||||
} else {
|
||||
$self->{caches}{file_checksums}{$self->{last_backup_id}} = my $file_checksums = {};
|
||||
my $sth = $self->{dbh}->prepare(
|
||||
"select file, checksum from versions2 v, instances i
|
||||
where session=? and v.id = i.version");
|
||||
$sth->execute($self->{last_backup_id});
|
||||
while (my ($file, $checksum) = $sth->fetchrow_array) {
|
||||
$file_checksums->{$file} = $checksum;
|
||||
}
|
||||
|
||||
return $file_checksums->{$file};
|
||||
}
|
||||
}
|
||||
|
||||
sub flush_insert_instances {
|
||||
my ($self) = @_;
|
||||
|
|
Loading…
Reference in New Issue