This topic describes how to execute hints on an ApsaraDB RDS for MySQL instance.

  • If you use the MySQL command-line interface (CLI) to connect to your database system, you must add the -c parameter to the hints that you want to execute. If you do not add this parameter to the hints, the MySQL CLI filters out the hints.
  • You can use the /*FORCE_MASTER*/ hint to specify to query data from the primary RDS instance. You can also use the /*FORCE_SLAVE*/ hint to specify to query data from the secondary RDS instance.
    Note
    • Hints are not subject to consistency or transaction limits. Therefore, hints have the highest route priorities. Before you execute hints, you must evaluate whether the hints are suitable for your workloads.
    • Hints cannot contain statements that are used to reconfigure environment variables. For example, the /*FORCE_SLAVE*/ set names utf8; command is not allowed. If you include these statements in hints, errors may occur in your subsequent workloads.
  • You can run the /*force_node='<The ID of an RDS instance>'*/ command to query data from a specified RDS instance. For example, if you specify the /*force_node='rr-bpxxxxx'*/ show processlist; command, the SHOW PROCESSLIST statement is executed only on the read-only RDS instance named rr-bpxxxxx. If the read-only RDS instance is faulty, the "force hint server node is not found, please check." error message is returned.
  • You can run the /*force_proxy_internal*/set force_node = '<The ID of an RDS instance>'; command to always query data from a specified RDS instance. For example, after you run the /*force_proxy_internal*/set force_node = 'rr-bpxxxxx'; command, all the subsequent commands are routed to the read-only RDS instance named rr-bpxxxxx. If the read-only RDS instance is faulty, the "set force node 'rr-bpxxxxx' is not found, please check." error message is returned.
    Note In most cases, we recommend that you do not use the /*force_proxy_internal*/ syntax. This syntax specifies to route all the subsequent requests to the specified RDS instance. As a result, the read/write splitting feature becomes invalid.