ClustrixDB breaks each representation (primary key + table or other index) into smaller, more manageable segments called “slices”, each of which is assigned a portion of the representation’s rows. There are multiple copies of each slice, called replicas.
To modify the number of slices for an existing table or index, follow this syntax:
ALTER TABLE tbl_name [SLICES = n] [ , INDEX index_name [SLICES = n]]
The following global variables impact ClustrixDB slicing.
|Name||Description||Default Value||Session Variable|
|hash_dist_min_slices||Controls how data is sliced. If set to 0, (the default), ClustrixDB will create new representations with the number of slices equal to the number of nodes currently in the cluster. At least one slice of the table or index is placed on each node. If set to a specific integer, that number of slices will be created for each new table and index instead.||0|
|rebalancer_split_threshold_kb||Controls the maximum slice size. By default, this is set to split slices greater than 1 GB.||1048576|
|task_rebalancer_reprotect_interval_ms||Defines how frequently the Rebalancer will assess if additional slices are needed. Specify 0 to disable slice splitting.||15000|
Generally, table and index slices should be 1-2 GB. The default size of 1 GB is optimal for most use cases. For clusters with very large tables (over 2TB in size), increasing the max slice size to 2 GB may be recommended.
Tables and indexes should have a minimum number of slices equal to the number of nodes, with ALLNODES tables being an exception. When adding nodes to your cluster, re-slicing of tables should be considered. Representations are not automatically resliced to match the number of nodes in the expanded cluster.
Use the following query to identify tables that contain fewer slices than the current number of nodes:
|Tables with fewer slices than the total number of nodes|
sql> SELECT fd.name `Database`, f.name `Table`, Count(*) Slices FROM system.slices JOIN system.representations fp USING (representation) JOIN system.relations f ON ( relation = `table` ) JOIN system.DATABASES fd USING (db) GROUP BY `Database`, `Table`, fp.name HAVING fd.name NOT IN ( 'system', 'clustrix_statd','clustrix_ui','_replication' ) AND slices < (SELECT Count(*) FROM system.membership WHERE status = 'quorum') AND (fp.name LIKE '%__PRIMARY%' OR fp.name LIKE '__base%') ORDER BY `Database`, `Table`, Slices;
During normal operation, relations are resliced on demand, however it can be advantageous to pre-slice tables for which large data growth is anticipated. Creating or altering a representation to have a slice count commensurate with the expected size will allow the cluster to add data to the representation at maximum speed as slice splitting will be unnecessary. For additional information, see Loading Data onto ClustrixDB.
Use the following equation to determine the optimal number of slices for a table: (expected table size + 10%) / rebalancer_split_threshold_kb)