Hint Filter allows services to interpret routing hints, which can be specified in a comment when a query is executed.
A query comment defines the routing behavior.
Several flavors of comment are supported. When using the double-hyphen style, whitespace is required after the double hyphen.
SELECT @@hostname; -- maxscale route to master SELECT @@hostname; # maxscale route to master SELECT @@hostname /* maxscale route to master */ ;
MaxScale Query Hint Filter is available for the Enterprise Server With Replica(s) topology.
MaxScale Query Hint Filter (
hintfilter) uses comments to route queries to the desired server. For cloud databases on SkySQL, this can be used to query status and configuration variable values on servers other than the Primary (master).
MaxScale Query Hint Filter is enabled by default. Query Hints are applied when executing queries via the Read/Write Port of the cloud database.
[Read-Write-Service] transaction_replay_retry_on_deadlock=true type=service user=maxscale_dbdgf12120236 connection_keepalive=200s filters=Hint master_failure_mode=fail_on_write password=asdfghjkl1234567890ASD! transaction_replay=true master_accept_reads=true router=readwritesplit transaction_replay_attempts=10 transaction_replay_max_size=10Mi
Route to Write Servers
To route to a server that accepts writes (the Primary):
SELECT @@hostname; -- maxscale route to master
Route to Read Servers
To route to a server that accepts reads:
SELECT @@hostname; -- maxscale route to slave
enabled, so queries routed to read servers may be routed to either the Primary or a Replica.
disabled, queries are routed only to Replicas. To disable
Route to a Specific Server
To route to a specific server:
SELECT @@hostname; -- maxscale route to server <server name>
Route to the Last Queried Server
To route to the server that processed the last query, allowing repeat querying of the same server:
SELECT @@hostname; -- maxscale route to last
Route by Replication Lag
To route to the server with replication lag lower than a threshold:
SELECT @@hostname; -- maxscale max_slave_replication_lag=<seconds>