Mysql works fin for the first time only?

Hi,
I am using perl 5.10.0 to get information from a log file and insert it into mysql 5.1.47 database. For the first execution of the program after rebooting my computer, the insertion of about 700 rows into two tables do not take more than 30 seconds. For the next execution, each row insertion take about 1minute.
Also, sometimes after several mysqld service restart, the execution return fast for only one execution.

Any idea…? please

This is the code:
sub connectDB {
my $dbaccess = DBAccess->new();
my ($driver,$db,$hostname,$user,$password) = $dbaccess->getDBInfo();
$dbops = DBOps->new($driver,$db,$hostname,$user,$password,“cbox”);
$dbh = $dbops->createHandler();
$dbh ? &printOK : &printNOK;
}

sub intilizeGettingLogs{
open (FILE,‘/var/log/OLSR.log’) or die “I could not open OLSR logs” ;
my $sth;
while(1){
my $line=<FILE>;
#36.1578s 0 [NODE 0] [10.0.0.1] 2-HOP Neighbour Set: [10.0.0.2->10.0.0.4 | 10.0.0.2->10.0.0.3]
if($line =~ /(\d{0,}\.\d{0,})(.)\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]\s2-HOP Neighbour Set:\s\[(.)\]/)
{
$current_time= $1;
$nodeIP= $3;
$neighborPair=$4;
if($neighborPair eq ‘’)
{
$sth = $dbh-> prepare(“insert into OLSR_2hop_Neighbors(node_ip, n1_ip, n2_ip, time) values (?,?,?,?)”);
$sth->execute($nodeIP,‘’,‘’,$current_time);
}
else{
while ($neighborPair =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\-\>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g)
{
$n1= $1;
$n2= $2;
$sth= $dbh-> prepare(“insert into OLSR_2hop_Neighbors(node_ip, n1_ip, n2_ip, time) values (?,?,?,?)”);
$sth->execute($nodeIP,$n1,$n2,$current_time);
}
}
}#end if
#36.1578s 0 [NODE 0] [10.0.0.1] Computed MPR set for node 10.0.0.1: [10.0.0.2]
elsif ($line =~ /(\d{0,}\.\d{0,})(.
)\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]\sComputed MPR set for node\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):\s\[(.*)\]/)
{
$current_time= $1 ;
$nodeIP= $3;
$MPR= $5;
if ($MPR eq ‘’)
{
$sth= $dbh-> prepare(“insert into OLSR_MPR_Info(node_ip, mpr_ip, time) values (?,?,?)”);
$sth->execute($nodeIP,‘’,$current_time);
}
else{
while ($MPR =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g)
{
$sth = $dbh-> prepare(“insert into OLSR_MPR_Info(node_ip, mpr_ip, time) values (?,?,?)”);
$sth->execute($nodeIP,$1,$current_time);
}
}
}#end if
}# end while

I’d recommend you have this moved to the perl forum. I have notified the moderator so you don’t need to do anything about it.

bazz

[SIZE=“4”]Hi all,
Thanks for your responses… event though i was suggested to change the forum :rolleyes:
Any way, the problem was that my program works as a thread in a general system…
ans i used the same connection used in the main program. But DBI module does not accept one connection to be used in several threads. So the solution was to create a new connection inside my thread.:smiley:

[/SIZE]

You seem displeased Malattar. :frowning:

I suggested changing forums only because none of your post showed any MySQL.
It was all perl and whilst it was relative to a Perl/MySQL setup, someone who specialises in MySQL wouldn’t have had a baldy notion what your had written because they don’t do php, let alone perl.

I am pleased, however, you got the matter resolved, which is after all, a perl issue - the DBI::module

bazz

Not sure IBazz was right about the move. My first thought would have been mysql or the configuration thereof.

I am not familiar with DBAccess and can find not reference to it. Do you have any information on it?

Are you noticing mysql or your perl app consuming CPU?