I am running the following PHP script that is called using a standard $.ajax call via jquery. This PHP script inserts multiple records into a database via a Stored Procedure. This procedure is a simple INSERT INTO.
The PHP script is
include_once '../Connections/define_connections.php';
$mysqli = new mysqli(DBHOST,DBUSER,DBPASS,DBNAME);
$mysqli->set_charset("utf8");
for ($q=0;$q<50000;$q++){
$varma = $mysqli->prepare("CALL insert_qq(?,?,?)");
$varma->bind_param('dds',$v1,$v2,$v3);
$v1 = '1';
$v2 = '2';
$v3 = '3';
$varma->execute();
};
$mysqli->close();
The Mysql Procedure is
DELIMITER $$
CREATE DEFINER=`loopmap`@`%` PROCEDURE `insert_qq`(in latitude double,in longitude double,
in placename varchar(100))
BEGIN
insert into GEO_Structure values (default,default,default,default,latitude,longitude,
default,default,default,default,default,default,default,default,default,
default,default,default,default,default,default,default,default,default,default,default,
placename,default,default,default);
END
The problem is that this code works ok when the number of loops is circa 10K, but when it is above that number, for example 50K as shown here some problems occur. Each record is inserted twice, indicating possibly that the stored procedure is called twice per loop.
This yields in this case 100K records in my database. I can also verify that something is wrong because firebug returns a red error ( but it is not specifying anything, nor any code, nor any description on the error encountered).
Interestingly, as I mentioned, when the loop goes up to 10K each record is inserted correctly (the stored procedure is called just once per loop) and firebug does not throw any error (it returns success). It would appear that there is a critical number of loops where this starts failing.