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

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.
  • 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 the master aggregator is responsible for managing metadata-level changes to partitions, it aggressively locks down partitions while performing the rebalance. If you run a workload against a master aggregator while REBALANCE executes, you will notice queries blocked for a significantly longer duration on the master aggregator (seconds) than on child aggregators (milliseconds). MemSQL extends the output of SHOW PARTITIONS with a Locked column that indicates whether the partition is locked locally on the aggregator.

Example

memsql> REBALANCE PARTITIONS ON test;
Query OK, 1 row affected (9.80 sec)