What is the simplest way to timeout a SELECT statement and handle the error?
<?php
$conn = mysqli_connect("localhost", "db", "user", "pass");
SELECT COUNT(1) FROM `table` WHERE...
I have tried the following without success.
$conn -> options(MYSQLI_OPT_CONNECT_TIMEOUT, 10);
$conn = mysqli_connect("localhost", "db", "user", "pass", connect_timeout=10);
SELECT /*+ MAX_EXECUTION_TIME(10) */ COUNT(1) FROM `table` WHERE...
SELECT SQL_TIMEOUT=10 FROM `table` WHERE..
All I want to do is abort the SELECT statement if the search term is too vague and too much time is spent scanning the table.
Pasting the following code just below the initial connection line does nothing. The query still takes about seven seconds and no error message is generated:
$conn->query('SET max_statement_time = 1'); // time in seconds