I want to UPDATE some hundreds of thousand of rows stored in Oracle database. For this I use PHP and transactions. But the whole process is extremely slow. This is what I do:
while (($row = oci_fetch_array($stid, OCI_ASSOC))) {
// define input for function
$id = $row['ID'];
$upstream_attn = $row['UPSTREAM_ATTN'];
$downstream_attn = $row['DOWNSTREAM_ATTN'];
$attainable_bitrate_adsl = $row['ATTAINABLE_BITRATE_ADSL'];
$stability = $row['STABILITY'];
$performance = $row['PERFORMANCE'];
$dsl_type = $row['DSL_TYPE'];
$snr_profile = $row['SNR_PROFILE'];
// execute function
$validationStatus = validatePerformanceData($upstream_attn,$downstream_attn,$attainable_bitrate_adsl,$stability,$performance,$dsl_type,$snr_profile); // return true or false
if ($validationStatus== 'OK'){
$stid_tmp = oci_parse($connection,"update " . ALUWS_DATA_HISTORICAL_TBL . " set VALIDATION_STATUS = 1 where ID = :id_bbn");
oci_bind_by_name($stid_tmp, ":id_bbn", $id);
$r_tmp = oci_execute($stid_tmp, OCI_NO_AUTO_COMMIT);
}
else{
$y = $y +1;
}
}
oci_commit($connection);
//disconnect from database
oci_close($connection);
The whole process takes for ages. I have added in the oci_execute function the mode: OCI_NO_AUTO_COMMIT in order to avoid auto commit but this didn't make a big difference.
Any other suggestions are mostly welcome.