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#54' and p_type not like 'MEDIUM PLATED%' and p_size in (7, 46, 14, 44, 5, 26, 43, 42) 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=317160.06..317542.11 rows=152820 width=44) Sort Key: (count(DISTINCT partsupp.ps_suppkey)) DESC, part.p_brand, part.p_type, part.p_size -> GroupAggregate (cost=223731.66..299297.13 rows=152820 width=44) Group Key: part.p_brand, part.p_type, part.p_size -> Gather Merge (cost=223731.66..291914.63 rows=585430 width=40) Workers Planned: 2 -> Sort (cost=222731.64..223341.46 rows=243929 width=40) Sort Key: part.p_brand, part.p_type, part.p_size -> Parallel Hash Join (cost=15090.16..194233.74 rows=243929 width=40) Hash Cond: (partsupp.ps_partkey = part.p_partkey) -> Parallel Index Only Scan using pk_partsupp on partsupp (cost=4.75..160795.46 rows=1666994 width=8) Filter: (NOT (hashed SubPlan 1)) SubPlan 1 -> Index Only Scan using supplier_s_suppkey_idx_like on supplier (cost=0.14..4.29 rows=10 width=4) -> Parallel Hash (cost=12608.12..12608.12 rows=121943 width=40) -> Parallel Index Only Scan using part_ios_test1 on part (cost=0.43..12608.12 rows=121943 width=40) Index Cond: (p_size = ANY ('{7,46,14,44,5,26,43,42}'::integer[])) Filter: ((p_brand <> 'Brand#54'::bpchar) AND ((p_type)::text !~~ 'MEDIUM PLATED%'::text)) (18 rows) COMMIT; COMMIT