TheRobotLearns Platform · ProxySQL: from first install to production
Configuration Tables and runtime_mysql_query_rules
Learning objectives
- Explain how mysql_query_rules is used for MySQL traffic routing decisions
- Distinguish configured query rules from their effective runtime_mysql_query_rules projection
- Relate LOAD MYSQL QUERY RULES TO RUNTIME and SAVE MYSQL QUERY RULES TO DISK to activation and persistence
- Identify tables storing routing, user, server, and runtime state for query analysis
Where MySQL routing decisions come from
You add a row in mysql_query_rules, but ProxySQL keeps using the older active row. The new row is still configuration. The active projection becomes available only after the relevant load step.
ProxySQL Admin stores MySQL configuration in tables. When you connect with admin-admin_credentials, the visible table list can include mysql_query_rules, mysql_query_rules_fast_routing, and runtime_mysql_query_rules. That list is not fixed. It may vary with the ProxySQL version and with the modules running.
The table mysql_query_rules configures query rules for MySQL traffic. mysql_query_rules_fast_routing configures query rules specialized in routing. runtime_mysql_query_rules holds the active form of configured query rules after the relevant load command. The runtime projection contains the corresponding active configuration. It may tighten constraints or add operational fields.
The Admin table list also includes mysql_users, mysql_servers, and runtime forms such as runtime_mysql_users and runtime_mysql_servers. Each runtime form is exposed after the relevant load command. You may not see every table on every deployment.
SHOW TABLES FROM main;Takeaway: mysql_query_rules stores the rule you write; runtime_mysql_query_rules stores the rule that is active.
Why runtime rows can differ
You compare mysql_query_rules and runtime_mysql_query_rules, and the rows do not look identical. The configured table and the active projection serve different roles.
mysql_query_rules stores the rules you edit through Admin. runtime_mysql_query_rules stores the active form after the relevant load command. The active projection contains the corresponding active configuration, and it may tighten constraints or add operational fields. A configured row is not the same thing as an active row until the load step has made it active.
You can inspect both sides after connecting with admin-admin_credentials.
SELECT * FROM mysql_query_rules;
SELECT * FROM runtime_mysql_query_rules;The first query reads the configured table. The second query reads the runtime projection for the same area. The runtime side updates after the relevant load step, not after a save step alone.
The visible table list can change with version and modules. The same pattern appears for users and servers: configured tables sit next to runtime forms such as runtime_mysql_users and runtime_mysql_servers.
Takeaway: mysql_query_rules is what you edit; runtime_mysql_query_rules is what is active.
Loading and saving query rules
The active forms are exposed in matching runtime tables after the relevant LOAD command. For mysql_query_rules, the runtime projection is runtime_mysql_query_rules. Only rules with active=1 are loaded into the runtime data structures and considered by the query processing module.
Run LOAD MYSQL QUERY RULES TO RUNTIME to expose active query rules in runtime_mysql_query_rules. After the load, inspect runtime_mysql_query_rules to confirm the active rules. Run SAVE MYSQL QUERY RULES TO DISK to save the query-rule configuration to disk.
LOAD MYSQL QUERY RULES TO RUNTIME;
SELECT * FROM runtime_mysql_query_rules;
SAVE MYSQL QUERY RULES TO DISK;Takeaway: Load query rules to update the runtime projection; save query rules to disk.
Tables to inspect together
You diagnose why a query does not match your new rule. You need the configured rule rows, the runtime rule rows, and the user and server tables listed in the MySQL configuration tables.
The MySQL table list includes routing, user, server, and runtime state. mysql_query_rules configures query rules for MySQL traffic. mysql_query_rules_fast_routing configures query rules specialized in routing. mysql_users configures frontend and backend MySQL users. mysql_servers configures backend MySQL servers, and mysql_servers_ssl_params configures backend server-specific SSL parameters.
The active side uses matching runtime tables. runtime_mysql_query_rules corresponds to configured query rules. runtime_mysql_query_rules_fast_routing corresponds to fast-routing rules. runtime_mysql_users corresponds to user configuration. runtime_mysql_servers and runtime_mysql_servers_ssl_params correspond to backend server configuration. These runtime projections contain active configuration and may tighten constraints or add operational fields.
SELECT * FROM runtime_mysql_query_rules;
SELECT * FROM runtime_mysql_users;
SELECT * FROM runtime_mysql_servers;Do not expect the table list to be identical everywhere. It may vary with the ProxySQL version in use and with the modules operating.
Takeaway: Routing, users, servers, and runtime projections are separate tables that you inspect together.
Compare configured and active query rules
SHOW TABLES FROM main;
SELECT * FROM mysql_query_rules;
LOAD MYSQL QUERY RULES TO RUNTIME;
SELECT * FROM runtime_mysql_query_rules;
SAVE MYSQL QUERY RULES TO DISK;SHOW TABLES FROM main lists configuration and runtime tables visible through Admin with admin-admin_credentials. SELECT * FROM mysql_query_rules reads configured query-rule rows from mysql_query_rules. LOAD MYSQL QUERY RULES TO RUNTIME activates the configured rows in the matching runtime projection. SELECT * FROM runtime_mysql_query_rules reads runtime_mysql_query_rules, the active form that may tighten constraints or add operational fields. SAVE MYSQL QUERY RULES TO DISK persists the configured query-rule rows in disk storage.
Try it: query_rule_playground
Connect to Admin using admin-admin_credentials. Run SHOW TABLES FROM main and note whether both mysql_query_rules and runtime_mysql_query_rules appear. Run SELECT * FROM mysql_query_rules;. Run SELECT * FROM runtime_mysql_query_rules;. If the configured rows differ from the runtime rows, run LOAD MYSQL QUERY RULES TO RUNTIME, then repeat the runtime SELECT. Finish by running SAVE MYSQL QUERY RULES TO DISK.
Sources
Do more with an account
- Graded quizzes is available on your account.
- Saving your progress is available on your account.
- Hands-on labs is available on your account.
- AI tutoring is available on your account.