Data partitioning and collecting in Datastage
Partitioning mechanism divides a portion of data into smaller segments, which is then processed independently by each node in parallel. It helps make a benefit of parallel architectures like SMP, MPP, Grid computing and Clusters.
Collecting is the opposite of partitioning and can be defined as a process of bringing back data partitions into a single sequential stream (one data partition).
Data partitioning methods
Datastage supports a few types of Data partitioning methods which can be implemented in parallel stages:
- default. Datastage Enterprise Edition decides between using Same or Round Robin partitioning. Typically Same partitioning is used between two parallel stages and round robin is used between a sequential and an EE stage.
- existing partitioning remains unchanged. No data is moved between nodes.
- rows are alternated evenly accross partitions. This partitioning method guarantees an exact load balance (the same number of rows processed) between nodes and is very fast.
- rows with same key column (or multiple columns) go to the same partition. Hash is very often used and sometimes improves performance, however it is important to have in mind that hash partitioning does not guarantee load balance and misuse may lead to skew data and poor performance.
- all rows from a dataset are distributed to each partition. Duplicated rows are stored and the data volume is significantly increased.
- rows are randomly distributed accross partitions
- an expensive refinement to hash partitioning. It is imilar to hash but partition mapping is user-determined and partitions are ordered. Rows are distributed according to the values in
one or more key fields, using a range map (the 'Write Range Map' stage needs to be used to create it). Range partitioning requires processing the data twice which makes it hard to find a reason for using it.
- data is partitioned on one specified numeric field by calculating modulus against number of partitions. Not used very often.
Data collecting methods
A collector combines partitions into a single sequential stream.
Datastage EE supports the following collecting algorithms:
- the default algorithm reads rows from a partition as soon as they are ready. This may lead to producing different row orders in different runs with identical data. The execution is non-deterministic.
- picks rows from input partition patiently, for instance: first row from partition 0, next from partition 1, even if other partitions can produce rows faster than partition 1.
- reads all rows from first partition, then second partition, then third and so on. Sort Merge
- produces a globally sorted sequential stream from within partition sorted rows.
Sort Merge produces a non-deterministic on un-keyed columns sorted sequential stream using the following algorithm: always pick the partition that produces the row with the smallest key value.