This topic describes the hint syntax for specifying a time-out period for SQL statements.

Information provided in this topic is applicable to Distributed Relational Database Service (DRDS) V5.3 and later.

In DRDS, the default time-out period for the SQL statements in DRDS instances and ApsaraDB RDS instances is 900 seconds. You can change the time-out period based on your requirements. Some SQL statements may take longer than 900 seconds to complete. For these slow SQL statements, DRDS provides a custom hint that you can use to change the time-out period for these statements. You can use this custom hint to change the time-out period for SQL statements.

Syntax

/*+TDDL:SOCKET_TIMEOUT(time)*/        

The value specified by SOCKET_TIMEOUT is measured in milliseconds. You can use this custom hint to change the time-out period for SQL statements based on your business requirements.

Note

  • DRDS custom hints can be specified in the /*+TDDL:hint_command*/ format or in the /!+TDDL:hint_command*/ format.
  • If you specify custom hints in the /*+TDDL:hint_command*/ format,add the -c parameter to the command used to log on to the MySQL command-line client: mysql. This way, you can execute SQL statements that contain the DRDS custom hints on the client. If you do not add the -c parameter,the client deletes comments in SQL statements before it sends the SQL statements to servers for execution. DRDS custom hints in this format are defined as MySQL comments. Therefore,the DRDS custom hints cannot take effect. For more information, see mysql client options.

Examples

Set the time-out period of SQL statements to 40 seconds:

/*+TDDL:SOCKET_TIMEOUT(40000)*/SELECT * FROM t_item;    
Note A longer timeout period causes database resources to be occupied for a longer period of time. If excessive SQL statements are executed over a long time within the same period, a large number of database resources may be consumed, and DRDS database services cannot be provided as expected. To resolve the issue, you must optimize SQL statements that take a long time to execute if possible.