Do not want to allow Queries to take more than x minutes ! What System variable can I set to automatically terminate it.
In mysql 5.7 ; you can use max_execution_time
From the documentation:
Statement Execution Time Optimizer Hints
MAX_EXECUTION_TIMEhint is permitted only for
SELECTstatements. It places a limit N (a timeout value in milliseconds) on how long a statement is permitted to execute before the server terminates it:
Example with a timeout of 1 second (1000 milliseconds):
SELECT /*+ MAX_EXECUTION_TIME(1000) */ * FROM t1 INNER JOIN t2 WHERE ...
MAX_EXECUTION_TIME(N)hint sets a statement execution timeout of N milliseconds. If this option is absent or N is 0, the statement timeout established by the max_execution_time system variable applies.
MAX_EXECUTION_TIMEhint is applicable as follows:
For statements with multiple
SELECTkeywords, such as unions or statements with subqueries,
MAX_EXECUTION_TIMEapplies to the entire statement and must appear after the first
It applies to read-only
SELECTstatements. Statements that are not read only are those that invoke a stored function that modifies data as a side effect.
It does not apply to
SELECTstatements in stored programs and is ignored.