set_replication_factor()

Sets the replication factor of a distributed hypertable to the given value. Changing the replication factor does not affect the number of replicas for existing chunks. Chunks created after changing the replication factor will be replicated in accordance with new value of the replication factor. If the replication factor cannot be satisfied, since the amount of attached data nodes is less than new replication factor, the command aborts with an error.

If existing chunks have less replicas than new value of the replication factor, the function will print a warning.

Required Arguments

NameDescription
hypertable(REGCLASS) Distributed hypertable to update the replication factor for.
replication_factor(INTEGER) The new value of the replication factor. Must be greater than 0, and smaller than or equal to the number of attached data nodes.

Errors

An error will be given if:

  • hypertable is not a distributed hypertable.
  • replication_factor is less than 1, which cannot be set on a distributed hypertable.
  • replication_factor is bigger than the number of attached data nodes.

If a bigger replication factor is desired, it is necessary to attach more data nodes by using attach_data_node.

Sample Usage

Update the replication factor for a distributed hypertable to 2:

  1. SELECT set_replication_factor('conditions', 2);

Example of the warning if any existing chunk of the distributed hypertable has less than 2 replicas:

  1. WARNING: hypertable "conditions" is under-replicated
  2. DETAIL: Some chunks have less than 2 replicas.

Example of providing too big of a replication factor for a hypertable with 2 attached data nodes:

  1. SELECT set_replication_factor('conditions', 3);
  2. ERROR: too big replication factor for hypertable "conditions"
  3. DETAIL: The hypertable has 2 data nodes attached, while the replication factor is 3.
  4. HINT: Decrease the replication factor or attach more data nodes to the hypertable.