I've been reading the TalendHPVerticaTipsAndTechniques pdf, and it mentions the following (see attached image):
{
If you are using the Talend Community Edition, you should add a WHERE clause to the original query to chunk the data. This example will result in 4 chunks.
original_sql + " and hash(" + primaryKey + ") % " + noOfThreads + " = " + i
Example:
select if.* from inventory_fact if, warehouse_dimension wd where if.warehouse_key = wd.warehouse_key
The query above results in the 4 queries below:
select if.* from inventory_fact if, warehouse_dimension wd where if.warehouse_key = wd.warehouse_key and hash(product_key, date_key) % 4 = 1;
select if.* from inventory_fact if, warehouse_dimension wd where if.warehouse_key = wd.warehouse_key and hash(product_key, date_key) % 4 = 2;
select if.* from inventory_fact if, warehouse_dimension wd where if.warehouse_key = wd.warehouse_key and hash(product_key, date_key) % 4 = 3;
select if.* from inventory_fact if, warehouse_dimension wd where if.warehouse_key = wd.warehouse_key and hash(product_key, date_key) % 4 = 4;
}
I am new to Vertica, and based on whatever I've read till now, I understand that Vertica creates a Superprojection that can be segmented across all nodes. What I'd like to understand is how the said Hash function in the WHERE clause will help in improving the performance. Will it create four buckets for the column values and read each of these bucket's data from different nodes in parallel? How is it different from segmenting the Projection? Or if the Projection is already segmented, how does this query work?
Any inputs on how the Hash function in the WHERE clause improves performance will be really helpful.
Thanks.