My application is a digital signage player. We need to send remote proof of play data back to the cloud on a regular basis. Proof of play data is cached to help with network interruptions.
A player can easily create 6,000 POP records in a day. When the network comes back up, this can cause a pretty serious delay moving from one presentation to the other.
I was looking at using the async mode of MySql to try and alleviate that delay... But I don't think it does what I think it does.
I'm I'm looping over a large result set, I'm still going to have to wait for that loop to complete. Do I bundle up 6,000 inserts and send them all at once? At what point does my AJAX return a result if I'm still waiting on an async database call? Does it just plain not work this way? Google returns less than a page of results, and the Docs don't really shed any light.
$sql = "SELECT MAX(time) from `pop` where `displayId` = ".$_GET['id'];
$res = $local->query($sql);
$row = $res->fetch_row();
//$log->lwrite("Last Updated is ".$row[0]);
$sql = "SELECT * FROM `pop`
WHERE `displayId` = ".$_GET['id']
." AND `time` > '".$row[0]."' LIMIT 1000";
$local->query($sql, MYSQLI_ASYNC);
if ($res = $local->reap_async_query()) {
while ($row = $res->fetch_row()) {
$log->lwrite(print_r($row, 1));
$sql = "INSERT INTO `pop`
(`displayId`, `time`, `duration`, `presId`)
VALUES ('".$row[1]."', '".$row[2]."', '".$row[3]."', '".$row[4]."')";
$remote->query($sql, MYSQLI_ASYNC);
}
}
I've already resigned myself to the notion that I'm going to have to do this a different way. Now I'm just curious. :)
Am I missing something here?
Thanks for your time and help.