SQL Routing
Under normal circumstances, the read-write separation function provided by the database proxy can effectively utilize the secondary database, thereby improving the throughput capacity of the entire database system. But in some cases, we also hope to route SQL to a specified database for execution to meet our business requirements. Here are some scenarios:
- Query statements want to avoid master-slave delay, route the statement to the master database to ensure real-time data
- Route data statistics and complex calculation query statements to the secondary database with a lower load weight, so as to separate it from the real-time business database
Enter SQL routing
Click on the proxy "details" to enter the details page
On the far right of the database proxy details page is the SQL routing function. Clicking the edit button will enter the SQL routing setting page.
In the upper left corner of the SQL routing page, there is a create routing button. Click to pop up a create SQL routing modal
Create SQL routing rules
Rate limiting can be set for SELECT type SQL statements on the SQL routing setting page
According to the actual business scenarios, enter the corresponding SQL statement, the system will automatically replace variables (like "hello world") with placeholders to adapt to the passed parameters
Depending on actual business needs, we can choose to route this SQL statement to master database/secondary database/custom database, where custom can be multi-selected.
Click ok, and you can see the rule has been added to the list
Modify routing type
After creating the SQL routing rule, the routing rule can be modified by clicking the Modify Routing Type button on the right side.
After clicking, modify the routing type in the pop-up box
Delete routing rule
SQL routing rules can be deleted, click the delete button on the right and then click ok to delete