Good Afternoon
Currently, I have a script in PHP that leads a CSV file of 6801 lines, and performs an INSERT as long as there are records. I'm currently able to insert 19 records per second.
In addition to this INSERT routine that runs every 5 minutes, users will connect to the database and so on.
I would like somehow to increase the 19reg / sec rate and still make simultaneous connections also perform well.
The source of the reading function follows:
error_reporting(0);
date_default_timezone_set('America/Sao_Paulo');
set_time_limit(600);
$server = "localhost";
$username = "root";
$password = "";
$database = "datab";
$conecta = mysql_connect($server, $username, $password) or print (mysql_error());
mysql_select_db($database, $conecta) or print(mysql_error());
function lerCsv(){
$handle = fopen("csv.csv", "r");
$num = 1;
$inicio = date("Y-m-d H:i:s");
Logger("Inicio da insercao -> ".$inicio);
while (!feof($handle) ) {
$linhas = fgetcsv($handle, 0);
$a= $linhas[0];
$b= $linhas[1];
$c= $linhas[2];
$d= $linhas[3];
$e= $linhas[4];
$f= $linhas[5];
$sql = "insert into bldatant values(null, '".$a."', '".$b."','".$c."','".$d."','".$e."','".$f."');";
if($query = mysql_query($sql)){
Logger("Registro ".$num." inserido com sucesso.".$sql);
$num++;
}
else{
Logger("Erro ao inserir registro".$num.". Erro->".mysql_error());
}
$sql="update blparams set valorparam=NOW() where nomeparam='BP_LASTUPD'";
$exc = mysql_query($sql);
}
fclose($handle);
mysql_close($conecta);
}