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#53' and p_type not like 'STANDARD ANODIZED%' and p_size in (8, 28, 41, 36, 13, 18, 45, 15) 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=3663103.56..3663173.24 rows=27872 width=40) Sort Key: (count(DISTINCT partsupp.ps_suppkey)) DESC, part.p_brand, part.p_type, part.p_size -> GroupAggregate (cost=582207.22..3661045.70 rows=27872 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=582207.22..3601316.85 rows=5945013 width=40) -> Sort (cost=4270227.37..4285089.90 rows=5945013 width=40) Sort Key: part.p_brand, part.p_type, part.p_size -> Hash Join (cost=582207.22..3601316.85 rows=5945013 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=542648.64..542648.64 rows=2972936 width=40) -> Bitmap Heap Scan on part (cost=57328.49..542648.64 rows=2972936 width=40) Recheck Cond: (p_size = ANY ('{8,28,41,36,13,18,45,15}'::integer[])) Filter: ((p_brand <> 'Brand#53'::bpchar) AND ((p_type)::text !~~ 'STANDARD ANODIZED%'::text)) -> Bitmap Index Scan on part_p_size_idx (cost=0.00..56585.26 rows=3203166 width=0) Index Cond: (p_size = ANY ('{8,28,41,36,13,18,45,15}'::integer[])) (22 rows) COMMIT; COMMIT