Outdated Version
You are viewing an older version of this section. View current production version.
REBALANCE PARTITIONS
Rebalances the partitions for a database.
Syntax
REBALANCE PARTITIONS ON db_name [FORCE]
Remarks
db_nameis the name of a MemSQL database.REBALANCE_PARTITIONSrestores redundancy by replicating any partitions with only one instance, and then moving partitions around to ensure balance across all the leaves. UseRESTORE REDUNDANCYinstead if you want to restore redundancy only, without rebalancing partitions.- The
FORCEoption causes rebalance to create empty partitions for any partition on the cluster which has neither a master nor replica partition attached. Use this option carefully. If an offline node has the only copy of a partition then runningREBALANCEwithFORCEwill cause the offline node’s partition to be orphaned. When the offline node comes back online the partition won’t be attached back to the cluster. It will have been replaced with an empty partition by rebalance. For some example cases whereFORCEis useful, see Dealing with Failures. - To see a list of operations that the
REBALANCEis going to execute, run EXPLAIN REBALANCE PARTITIONS. - To see the status of a running rebalance command, run SHOW REBALANCE STATUS
- This command must be run on the master aggregator node (see Node Requirements for MemSQL Commands ).
REBALANCEis an online operation, meaning that as it runs you can continue to read and write data in the database you are rebalancing. However, sinceREBALANCEoften needs to move the location of a master partition to another leaf, write transactions may experience some temporary blocking during the rebalance as this happens.
Example
memsql> REBALANCE PARTITIONS ON test;
Query OK, 1 row affected (9.80 sec)