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