BEGIN; BEGIN EXPLAIN select s_name, s_address from supplier, nation where s_suppkey in ( select ps_suppkey from partsupp where ps_partkey in ( select p_partkey from part where p_name like 'steel%' ) and ps_availqty > ( select 0.5 * sum(l_quantity) from lineitem where l_partkey = ps_partkey and l_suppkey = ps_suppkey and l_shipdate >= '1994-01-01' and l_shipdate < cast(date '1994-01-01' + interval '1 year' as date) ) ) and s_nationkey = n_nationkey and n_name = 'VIETNAM' order by s_name; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop Semi Join (cost=4119.79..2816124.78 rows=1071 width=52) -> Gather Merge (cost=4118.93..4574.81 rows=4000 width=56) Workers Planned: 1 -> Sort (cost=3118.92..3124.80 rows=2353 width=56) Sort Key: supplier.s_name -> Hash Join (cost=1.32..2987.15 rows=2353 width=56) Hash Cond: (supplier.s_nationkey = nation.n_nationkey) -> Parallel Seq Scan on supplier (cost=0.00..2805.24 rows=58824 width=60) -> Hash (cost=1.31..1.31 rows=1 width=4) -> Seq Scan on nation (cost=0.00..1.31 rows=1 width=4) Filter: (n_name = 'VIETNAM'::bpchar) -> Nested Loop (cost=0.86..702.88 rows=1 width=4) -> Index Scan using partsupp_ps_suppkey_idx on partsupp (cost=0.43..689.45 rows=26 width=8) Index Cond: (ps_suppkey = supplier.s_suppkey) Filter: ((ps_availqty)::numeric > (SubPlan 1)) SubPlan 1 -> Aggregate (cost=8.59..8.61 rows=1 width=32) -> Index Only Scan using lineitem_l_partkey_l_suppkey_l_shipdate_l_quantity_idx on lineitem (cost=0.56..8.59 rows=1 width=5) Index Cond: ((l_partkey = partsupp.ps_partkey) AND (l_suppkey = partsupp.ps_suppkey) AND (l_shipdate >= '1994-01-01'::date) AND (l_shipdate < '1995-01-01'::date)) -> Index Scan using pk_part on part (cost=0.43..0.52 rows=1 width=4) Index Cond: (p_partkey = partsupp.ps_partkey) Filter: ((p_name)::text ~~ 'steel%'::text) (22 rows) COMMIT; COMMIT