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_name is the name of a MemSQL database.
  • REBALANCE_PARTITIONS restores redundancy by replicating any partitions with only one instance, and then moving partitions around to ensure balance across all the leaves. Use RESTORE REDUNDANCY instead if you want to restore redundancy only, without rebalancing partitions.
  • The FORCE option 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 running REBALANCE with FORCE will 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 where FORCE is useful, see Dealing with Failures.
  • To see a list of operations that the REBALANCE is 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 ).
  • REBALANCE is an online operation, meaning that as it runs you can continue to read and write data in the database you are rebalancing. However, since REBALANCE often 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)