Updated on 2022-09-16 GMT+08:00

Customized Hints for Read/Write Splitting

DDM allows you to customize a hint to specify whether SQL statements are executed on the primary instance or its read replicas.

The following hint formats are supported:

  • /*!mycat:db_type=host*/
  • /*+ db_type=host */

host can be master or slave. master indicates a primary instance, and slave indicates a read replica.

Currently, this function only applies to SELECT statements.

After read/write splitting is enabled, write operations are performed only on the primary DB instance, and read operations are performed only on its read replicas. To read from the primary instance, you can customize a hint to forcibly perform read operations on the primary instance. This method is only suitable for queries.