Routing Statements with MaxScale's Read/Write Split Router

Understand the routing logic of the readwritesplit router. This guide explains how MaxScale identifies write statements for the primary and distributes reads to replicas.

The Read/Write Split Router (readwritesplit) uses well-defined rules to determine whether a statement can be routed to a replica server, or whether it needs to be routed to the primary server. Application designers must understand these rules to ensure that the router can properly load balance queries.

Statements Routed to the Primary Server

The following statements are routed to the primary server:

For example, all queries will be routed to the primary server in this case:

And all queries will also be routed to the primary server in this case:

  • Queries using stored procedures

  • Queries using stored functions

  • Queries using user-defined functions (UDF)

  • Queries that use temporary tables

  • EXECUTEarrow-up-right statements that execute prepared statements

Statements Routed to a Replica Server

The following statements are routed to a replica server:

For example, the following queries would be routed to a replica:

  • Queries using built-in functions

Statements Routed to All Servers

The following statements are routed to all servers:

This page is: Copyright © 2025 MariaDB. All rights reserved.

spinner

Last updated

Was this helpful?