SET scaleout_tables_preferred_member
Aurora MySQL only. Names the member table that describes a scaleout table in this session of a database cluster group for Aurora. The variable answers SHOW CREATE TABLE, SHOW COLUMNS, SHOW INDEX, and DESCRIBE on a scaleout table, which drivers, ORMs, and schema tools depend on.
Description
A scaleout table has no table of its own on a member cluster, so these statements answer from the member table that the session names. If the variable isn't set, or names a table that isn't a member of the scaleout table, the statement fails with error 1146. When the variable names a member table, SHOW CREATE TABLE shows the member table's name in its Table column.
For how the routing layer holds the variable, see scaleout_tables_preferred_member.
Syntax
SET [SESSION] scaleout_tables_preferred_member = 'scaleout_table:db.member_table[,scaleout_table:db.member_table...]';
Parameters and options
The statement takes the following parameters.
scaleout_table-
The scaleout table name alone, without its database.
db.member_table-
One of its member tables, by the router database name and router table name that its data mapping gives it, not by its cluster name. To name member tables for several scaleout tables, separate the pairs with commas.
Where it runs and required privileges
Run the statement at the routing endpoint, in a session that isn't pinned. In a pinned session, describe the member table by its cluster name instead. The statement needs no privilege for database cluster groups for Aurora, and the routing layer doesn't send it to a member cluster. For the full list of these privileges, see Privileges.
Usage notes
The routing layer holds the variable for the session. Set it before the first metadata statement on a scaleout table.
In a new connection the variable is empty. Read it with SELECT @@scaleout_tables_preferred_member or SHOW VARIABLES; the routing layer answers both and never sends the variable to a member cluster. Set it to '' to clear it. Set it in a SET statement of its own: a SET that also assigns another variable returns error 1235. When you set it, the routing layer checks only the format of the value and returns error 1231 for a malformed value. It doesn't check that the named tables exist, so a wrong name returns error 1146 on the next SHOW or DESCRIBE.
Examples
The following example reads the definition of app.orders from its member table app.orders_m3.
SET SESSION scaleout_tables_preferred_member = 'orders:app.orders_m3'; SHOW CREATE TABLE app.orders;
Errors
The statement can return the following errors. For all errors from the routing layer, see Error codes for database cluster groups for Aurora.
| Aurora MySQL | Meaning |
|---|---|
| 1231 (42000) | Variable can't be set to this value: the value isn't a comma-separated list of scaleout_table:member pairs, or it has more than 25,000 pairs. |
| 1235 (42000) | The SET statement also assigns another variable. Set scaleout_tables_preferred_member on its own. |
1146 (on the SHOW or DESCRIBE statement) |
The variable isn't set, or names a table that isn't a member of the scaleout table. |
Related statements
For more information, see the following: