tencent cloud

TDSQL for MySQL

Read/Write Separation

下载
聚焦模式
字号
最后更新时间: 2024-01-06 17:34:55
TDSQL for MySQL instances support read/write separation in the following modes:
A replica comment flag such as /*slave*/ can be added in a SQL statement, and the -c parameter is added after mysql to parse mysql -c -e "/*slave*/sql" to send the SQL statements to the replica server.
Note:
Comment flags including /*slave:slaveonly*/, /*slave:20*/, and /*slave:slaveonly,20*/ are also supported, where their values indicate the delay requirement that the replica server should satisfy, and slaveonly indicates that the query will not be sent to the source server if there is no eligible replica server.
//Read data from source//
select * from emp order by sal, deptno desc;
//Read data from replica//
/*slave*/ select * from emp order by sal, deptno desc;
Requests sent by read-only accounts are sent to the replica server based on the configured attributes.


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈