Skip to content
Snippets Groups Projects
Commit f9bc0854 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- use explicite transaction to increase performance

- fixed multiple connect/disconnect calls to db in inner loop
parent a3458179
No related branches found
No related tags found
No related merge requests found
......@@ -205,6 +205,7 @@ SQL_LOCAT_PLAN
(SELECT id FROM aip WHERE aip.ie_id=\$1 AND aip.version=\$2), \$3, \$4
);
SQL_DC_PLAN
$dbh->begin_work;
my $sth_aip_plan = $dbh->prepare($sql_aip_plan);
my $sth_ie_plan = $dbh->prepare($sql_ie_plan);
my $sth_file_plan = $dbh->prepare($sql_file_plan);
......@@ -226,6 +227,7 @@ SQL_DC_PLAN
$dcvalue=~tr/'/"/;
$sth_dc_plan->execute($ieid, $ieversion, $dckey, $dcvalue) or die "sql problem detected", $dbh->errstr;
}
$dbh->commit;
return 1;
}
......@@ -530,20 +532,19 @@ my $cnt_unsorted_files = searching_ie_files(\@dirs, $tmp_ies_unsorted_file);
my $fh_unsorted_IEs = $tmp_ies_unsorted_file->openr();
my $count = 0;
my $progressbar = Time::Progress->new(min => 0, max => $cnt_unsorted_files, smoothing => 1);
my $dbh = DBI->connect("dbi:SQLite:dbname=$db_filename", "", "", {
RaiseError => 1,
sqlite_unicode => 1,
}) or die "could not connect to database (file '$db_filename')", $DBI::errstr;
while (<$fh_unsorted_IEs>) {
chomp;
print $progressbar->report("parse IE files: %40b ETA: %E \r", $count++);
s/V0*(\d+-IE)/V$1/; # revert fake version
my $ret = parse_iexml($_, $flag_recovery);
my $dbh = DBI->connect("dbi:SQLite:dbname=$db_filename", "", "", {
RaiseError => 1,
sqlite_unicode => 1,
}) or die "could not connect to database (file '$db_filename')", $DBI::errstr;
write_addsql($dbh, $ret);
$dbh->disconnect or warn("disconnecting problems, ", $dbh->errstr);
}
$dbh->disconnect or warn("disconnecting problems, ", $dbh->errstr);
say "\rprocessed $count uniq IEs ";
say "";
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment