Skip to main content

Query Annotations

Overview

ProxySQL supports query annotations to customize individual query behaviour. Annotations are included in comments preceding queries:

SELECT /*+ ;cache_ttl=0;query_timeout=100 */ c FROM sbtest3 WHERE id=2

Annotations override global variable settings for specific queries. ProxySQL evaluates annotations before query rules, so mysql_query_rules settings may supersede annotations.

Supported Annotations

AnnotationPurpose
cache_ttlCache duration in milliseconds
query_delayDelay before processing (milliseconds)
query_retriesNumber of retry attempts
query_timeoutMaximum execution time (milliseconds)
hostgroupTarget hostgroup destination
mirrorActivates query mirroring with mirror_hostgroup
max_lag_msMaximum Aurora replica replication lag
min_epoch_msMinimum epoch time threshold for server selection
min_gtidMinimum required GTID on target server
create_new_connectionForces new backend connection instead of reusing pooled connection