develooper Front page | perl.fwp | Postings from October 2002

Mysql performace 30000 record

Thread Next
From:
Davide Copelli
Date:
October 1, 2002 05:54
Subject:
Mysql performace 30000 record
Message ID:
001a01c26922$aff579a0$0200a8c0@chost
I need to execute multiply query on a Mysql database with 30000 record

I use this code to read a txt file with 50 records (eg. page1 , page 2, page
3 etc) and then execute some query
(the code is ok):

.....
.....

open (INPUT, "< $filepageid") || &file_open_error("$filepageid");

while ($riga=<INPUT>){
$nump++;
chop($riga);
$pagina[$nump] = $riga;

$sth= $dbh->prepare("SELECT count(*) FROM lognew WHERE
pageid='$pagina[$nump]' and data>='$startdate'");
$sth->execute;
$totalvisit[$nump] = $sth->fetchrow_array();

$sth = $dbh->prepare("SELECT count(*) FROM lognew WHERE
(pageid='$pagina[$nump]' and data='$dataoggi')");
$sth->execute;
$totalvisittoday[$nump] = $sth->fetchrow_array();

 $sth = $dbh->prepare("SELECT count(*) FROM lognew WHERE
(pageid='$pagina[$nump]' and data='$dataieri')");
$sth->execute;
$totalyvisit[$nump] = $sth->fetchrow_array();

 $sth= $dbh->prepare("SELECT count(*) FROM lognew WHERE
(pageid='$pagina[$nump]' and data<='$fine30gg' and data>='$inizio30gg')");
$sth->execute;
$totalmvisit[$nump] = $sth->fetchrow_array();

 }

close (INPUT);

The question is:

Using the same statement object $sth can affect MySql performance ?
Are there altenative ways to optimize this routine ?
Are 30000 records to much for this kind of query ?

Thank you very much !






Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About