BEGIN; BEGIN EXPLAIN select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt from partsupp, part where p_partkey = ps_partkey and p_brand <> 'Brand#33' and p_type not like 'MEDIUM BURNISHED%' and p_size in (11, 48, 26, 16, 10, 1, 24, 19) and ps_suppkey not in ( select s_suppkey from supplier where s_comment like '%Customer%Complaints%' ) group by p_brand, p_type, p_size order by supplier_cnt desc, p_brand, p_type, p_size; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=3662815.85..3662885.45 rows=27842 width=40) Sort Key: (count(DISTINCT partsupp.ps_suppkey)) DESC, part.p_brand, part.p_type, part.p_size -> GroupAggregate (cost=582047.74..3660760.42 rows=27842 width=40) Group Key: part.p_brand, part.p_type, part.p_size -> Remote Subquery Scan on all (datanode_1_1,datanode_2_1,datanode_3_1,datanode_4_1,datanode_5_1,datanode_6_1,datanode_7_1,datanode_8_1) (cost=582047.74..3601094.62 rows=5938738 width=40) -> Sort (cost=4269253.86..4284100.71 rows=5938738 width=40) Sort Key: part.p_brand, part.p_type, part.p_size -> Hash Join (cost=582047.74..3601094.62 rows=5938738 width=40) Hash Cond: (partsupp.ps_partkey = part.p_partkey) -> Seq Scan on partsupp (cost=2396.87..2712056.27 rows=40000016 width=8) Filter: (NOT (hashed SubPlan 1)) SubPlan 1 -> Remote Subquery Scan on all (datanode_4_1) (cost=4.30..2395.13 rows=697 width=4) -> Bitmap Heap Scan on supplier (cost=4.30..2395.13 rows=697 width=4) Recheck Cond: ((s_comment)::text ~~ '%Customer%Complaints%'::text) -> Bitmap Index Scan on supplier_s_suppkey_idx_like (cost=0.00..4.13 rows=697 width=0) -> Hash (cost=542528.39..542528.39 rows=2969798 width=40) -> Bitmap Heap Scan on part (cost=57278.59..542528.39 rows=2969798 width=40) Recheck Cond: (p_size = ANY ('{11,48,26,16,10,1,24,19}'::integer[])) Filter: ((p_brand <> 'Brand#33'::bpchar) AND ((p_type)::text !~~ 'MEDIUM BURNISHED%'::text)) -> Bitmap Index Scan on part_p_size_idx (cost=0.00..56536.14 rows=3200352 width=0) Index Cond: (p_size = ANY ('{11,48,26,16,10,1,24,19}'::integer[])) (22 rows) COMMIT; COMMIT