Arunkumarpro has asked for the wisdom of the Perl Monks concerning the following question:
I am using to Perl DBI to select and process data from an MS Access database.The code works well but it is very slow.It takes 3-4 minutes to select data from my database which has only around 150 records. I am preparing the statements outside the loop only.Tried using the fetchrow_array,fetchrow_arrayref,fetchall_arrayref methods,but the performance does not differ much.How can i improve the speed of execution?
my $dbh = DBI->connect('dbi:ODBC:driver=Microsoft Access Driver (*.mdb +, *.accdb);dbq=D:\Project\Project\BSC_KPIMonitoring\CHN\E_BSC_KPIMoni +torDB.mdb'); my $stat1="SELECT * FROM SDCCHBLOCKING WHERE NE=?"; my $sth1 = $dbh->prepare($stat1); my $stat2="SELECT * FROM SDCCHDROP WHERE NE=?"; my $sth2 = $dbh->prepare($stat2); my $stat3="SELECT * FROM TCHBLOCKING WHERE NE=?"; my $sth3 = $dbh->prepare($stat3); my $stat4="SELECT * FROM TCHDROP WHERE NE=?"; my $sth4 = $dbh->prepare($stat4); my $sqlstatement="SELECT * FROM KPI_Master"; my $sth = $dbh->prepare($sqlstatement); $sth->execute || die "Could not execute SQL statement ... maybe invalid?"; while (my @row=$sth->fetchrow_array()){ $bsc = $row[0]; $kpi = $row[1]; $thresh= $row[2]; if($kpi eq "SDCCHBLOCKING") { $sth1->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row1=$sth1->fetchrow_array()) { if($row1[2]>$thresh) { print "SB,$bsc,$thresh,/$row1[2]"; } } } if($kpi eq "SDCCHDROP") { $sth2->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row2=$sth2->fetchrow_array()) { if($row2[2]>$thresh) { print "SD,$bsc,$thresh,/$row2[2]"; } } } if($kpi eq "TCHBLOCKING") { $sth3->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row3=$sth3->fetchrow_array()) { if($row3[2]>$thresh) { print "TB,$bsc,$thresh,/$row3[2]"; } } } if($kpi eq "TCHDROP") { $sth4->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row4=$sth4->fetchrow_array()) { if($row4[2]>$thresh) { print "TD,$bsc,$thresh,/$row4[2]"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl DBI
by poj (Abbot) on Jun 29, 2013 at 20:25 UTC | |
by Arunkumarpro (Initiate) on Jun 29, 2013 at 20:49 UTC | |
by poj (Abbot) on Jun 30, 2013 at 07:12 UTC | |
by Arunkumarpro (Initiate) on Jun 30, 2013 at 20:02 UTC | |
by poj (Abbot) on Jun 30, 2013 at 20:09 UTC | |
by Arunkumarpro (Initiate) on Jun 30, 2013 at 20:23 UTC | |
by poj (Abbot) on Jun 30, 2013 at 20:33 UTC | |
| |
|
Re: Perl DBI
by erix (Prior) on Jun 30, 2013 at 10:35 UTC | |
by Anonymous Monk on Jun 30, 2013 at 13:15 UTC | |
|
Re: Perl DBI
by Anonymous Monk on Jun 30, 2013 at 10:03 UTC | |
|
Re: Perl DBI
by rpnoble419 (Pilgrim) on Jun 30, 2013 at 03:06 UTC |