Xpand 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] [split_threshold_kb = n]]
The following global variables impact Xpand slicing.
|Name||Description||Default Value||Session Variable|
|hash_dist_min_slices||Controls how data is sliced. If set to 0, (the default), Xpand 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||Default size at which the rebalancer splits slices.|
|task_rebalancer_reprotect_interval_ms||Defines how frequently the Rebalancer will assess if additional slices are needed. Specify 0 to disable slice splitting.||15000|
The default slice size of 8 GB is optimal for most use cases. If a very large table results in more slices than available cores, performance might be impacted and increasing the max slice size 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. 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 Xpand.
Use the following equation to determine the optimal number of slices for a table: (expected table size + 10%) / rebalancer_split_threshold_kb)
The Rebalancer automatically splits a table slice or index slice when it reaches the threshold set by the global rebalancer_split_threshold_kb. However, some tables might benefit from more slices (for increased parallelism) or fewer slices (to reduce overhead of slices on the system).