Thanks all I'm learning a lot here.
i got all the data and now my new issue is I have this huge insert but nothing is getting inserted:
php:
mysql_query('INSERT INTO ibf_cdx_stockmanager_daily (ticker, nst_unix, avg, min, max, open, close) VALUES ' . $insertStr);
$inserStr has about ~29k inserts.
("AAVL",1311058800,20,20,20,20,20),("ACFI",1311058800,8.58,7,9,8,9),......................
try - instead of creating one huge insert - creating many inserts in one transaction using prepared statements for increased performance (the query only has to be parsed once, but is executed often with different values)
i.e. something along the lines of this (using PDO):
$data = array(array(first data set), array(second data set), ...);
$connection = new PDO('mysql:host=yourdbhost;dbname=yourdbname', $user, $pass);
$query = $db_connection->prepare('INSERT INTO ibf_cdx_stockmanager_daily (ticker, nst_unix, avg, min, max, open, close) VALUES (?,?,?,?,?,?,?)');
try
{
$connection->beginTransaction();
for($i = 0; $i < $data.length; ++$i)
{
$query->execute($data[$i]);
}
$connection->commit();
}
catch(Exception $e)
{
$connection->rollBack();
echo $e->getMessage();
}
note that the data doesn't have to be available all at once, e.g. you could also grab the data between the beginTransaction and commit by some means and execute the query there as you get the data
also you can use named identifiers instead of enumerated ones, in this case the "(?,?,...)" would change to something like "(:ticker,:time,:avg,...)" and instead of having a simple array for each data set, you'd have an associative array with the keys matching your placeholders "array(ticker=>"whatever", time=>"...", ...)"