Oracle SQL PHP INSERT speed optimization? -


i'm trying insert lot of data oracle sql db, doing following...

foreach ($service $valor) {     $j=0;     foreach($fechahorainf $fecha){         $i=0;         $consulta="insert prueba_sms(fechahorainf,servicio,valor) values (to_date('".$fecha."','dd/mm/yyyy hh24:mi:ss'),'".$valor."','".$data[$j][$i]."')";         $stmt = oci_parse($conexion, $consulta);         oci_execute($stmt,oci_default);         $i++;     }     oci_commit($conexion);     oci_free_statement($stmt);     $j++; } 

note count($j)=count($service)=30 , count($i)=count($fechahorainf)=720

the point here i'm going insert 21600 rows , takes lot of time.

is there tip improve speed?

update: tried load date infile daan , citywall sugested way:

$consulta="load data local infile 'files/data.csv' table prueba_sms fields terminated ';' lines terminated '\n' (fechahorainf,nodo,servicio,valor)"; $stmt=oci_parse($conexion, $consulta); oci_execute($stmt); 

but receive warning without information... warning: oci_execute(): in c:\path_to_archive.php on line 160

regards!

in case load data reason not option you, steps recommend taking improve speed:

1) make sure there no auto-commit going on. committing yes, if there no transaction without auto-commit going on, not matter. since using oci_default there should no auto-commit.

2) not parse sql every insert ... reuse parsed sql , replace values insert using oci_bind_by_name .. see second sample on how this. should speed insert lot ... , optimize network traffic, sql parsing resources @ db , on.

3) instead of committing every group, count inserts , try out optimal commit rate - last point not think matter lot in case.

i try out step 2 , see how can gain avoiding parse sql every insert ...


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -