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#13' and p_type not like 'LARGE POLISHED%' and p_size in (4, 8, 2, 3, 17, 25, 21, 11) 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=3661622.93..3661692.24 rows=27724 width=40) Sort Key: (count(DISTINCT partsupp.ps_suppkey)) DESC, part.p_brand, part.p_type, part.p_size -> GroupAggregate (cost=581368.74..3659577.06 rows=27724 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=581368.74..3600164.03 rows=5913579 width=40) -> Sort (cost=4265311.57..4280095.52 rows=5913579 width=40) Sort Key: part.p_brand, part.p_type, part.p_size -> Hash Join (cost=581368.74..3600164.03 rows=5913579 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_8_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=542006.65..542006.65 rows=2957217 width=40) -> Bitmap Heap Scan on part (cost=57072.70..542006.65 rows=2957217 width=40) Recheck Cond: (p_size = ANY ('{4,8,2,3,17,25,21,11}'::integer[])) Filter: ((p_brand <> 'Brand#13'::bpchar) AND ((p_type)::text !~~ 'LARGE POLISHED%'::text)) -> Bitmap Index Scan on part_p_size_idx (cost=0.00..56333.40 rows=3187718 width=0) Index Cond: (p_size = ANY ('{4,8,2,3,17,25,21,11}'::integer[])) (22 rows) COMMIT; COMMIT