I want to set a timeout for all the select queries hitting on MySQL Server. So that if the read query is taking a long time then i can throw a timeout exception. I know this feature is provided in MySQL 5.7 by:
SET GLOBAL MAX_STATEMENT_TIME=1000;
or
SET GLOBAL MAX_EXECUTION_TIME=1000;
But the problem is that MySQL 5.7 is not provided in AWS RDS. I am using MySQL 5.6 on RDS. Please tell me is there any alternate way to do this in 5.6 I am a new to mysql and RDS. Please help me out.
I know this question is about MySQL v5.6.1 - but maybe this helps other visitors: You can find out what version/parameter is supported and edit it like this:
1) Go to https://console.aws.amazon.com/rds/ and select "Parameter groups" in the menu on the left.
2) Select the parameter group you used for your database instance and in the dropdown "Parameter group actions" choose "edit".
Now depending on your database version the parameter might be called max_statement_time
or in later versions max_execution_time
.
3) Search for one of those parameters and click "Edit parameters".
be aware that max_statement_time
is in seconds and max_execution_time
in milliseconds. So if you want your query to be terminated after 1 second its either:
max_statement_time = 1
or
max_execution_time = 1000
To be sure, read the explanation on the right column to see what the parameter does.
4) Then set the new value you want.
5) "Save changes" and wait for the parameter group being applied to the database instance (you might have to select "apply immediately" or just reboot afterwards).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With