PolarDB-X provides custom HINT statements that you can use to modify the SQL timeout period.
PolarDB-X applies a default timeout of 900 seconds to SQL statements sent from compute nodes to storage nodes. For slow SQL statements that legitimately need a longer execution window, use the SOCKET_TIMEOUT hint to set a per-statement timeout.
Usage notes
- PolarDB-X hints support two formats:
/*+TDDL:hint_command*/and/!+TDDL:hint_command*/. - When using the
/*+TDDL:*/format in the official MySQL command-line client, add the-cflag at login. Without-c, the client strips PolarDB-X hints — before sending statements to the server. For details, see MySQL comments and mysql client options.
Syntax
/*+TDDL:SOCKET_TIMEOUT(time)*/
Specify time in milliseconds.
Example
Set a 40-second timeout for a SELECT statement:
/*+TDDL:SOCKET_TIMEOUT(40000)*/SELECT * FROM t_item;
Important A longer timeout keeps database resources occupied for the full duration of the statement. If many long-running SQL statements run concurrently, resource exhaustion can degrade PolarDB-X availability. Optimize long-running SQL statements rather than relying on extended timeouts.