I am exploring the possibility of setting a timeout/stopping a specific query in PHP and MySQLi.
Slightly modified example from php.net:
if ($stmt = $mysqli->prepare("INSERT NESTED MYSQL QUERY HERE.")) {
$stmt->bind_param("s", $city);
$stmt->execute();
$stmt->set_timeout("50000"); //hypothetical, will not work
$stmt->bind_result($district);
while($stmt->fetch()){
//to do
}
}
$mysqli->close();
Is this possible?
Ideal implementation:
- Inside PHP code and not through configuration of MySQL server
- Can be implemented only for selected queries and not to all queries
- Works (at a minimum) on MySQL 5.6 and beyond
- Can inform the end user, e.g.
The process took long than expected. Try to split your dataset into segments.