BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select s_name, s_address from supplier, nation where s_suppkey in ( select distinct (ps_suppkey) from partsupp, part where ps_partkey=p_partkey and p_name like 'antique%' and ps_availqty > ( select 0.5 * sum(l_quantity) from lineitem where l_partkey = ps_partkey and l_suppkey = ps_suppkey and l_shipdate >= '1993-01-01' and l_shipdate < cast(date '1993-01-01' + interval '1 year' as date) ) ) and s_nationkey = n_nationkey and n_name = 'GERMANY' order by s_name; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=12740713.76..12740716.68 rows=1169 width=51) (actual time=47546.954..47547.124 rows=1807 loops=1) Sort Key: supplier.s_name Sort Method: quicksort Memory: 256kB Buffers: shared hit=2711882 read=393143 dirtied=1463 written=9210 -> Nested Loop (cost=12736248.97..12740654.19 rows=1169 width=51) (actual time=47354.598..47536.322 rows=1807 loops=1) Join Filter: (supplier.s_nationkey = nation.n_nationkey) Rows Removed by Join Filter: 43095 Buffers: shared hit=2711877 read=393143 dirtied=1463 written=9210 -> Seq Scan on nation (cost=0.00..1.31 rows=1 width=4) (actual time=0.013..0.027 rows=1 loops=1) Filter: (n_name = 'GERMANY'::bpchar) Rows Removed by Filter: 24 Buffers: shared hit=1 -> Hash Semi Join (cost=12736248.97..12740287.69 rows=29215 width=55) (actual time=47354.476..47527.045 rows=44902 loops=1) Hash Cond: (supplier.s_suppkey = partsupp.ps_suppkey) Buffers: shared hit=2711876 read=393143 dirtied=1463 written=9210 -> Seq Scan on supplier (cost=0.00..3179.00 rows=100000 width=59) (actual time=0.013..50.121 rows=100000 loops=1) Buffers: shared hit=2179 -> Hash (cost=12735883.78..12735883.78 rows=29215 width=4) (actual time=47354.418..47354.418 rows=44902 loops=1) Buckets: 4096 Batches: 1 Memory Usage: 1579kB Buffers: shared hit=2709697 read=393143 dirtied=1463 written=9210 -> HashAggregate (cost=12735299.48..12735591.63 rows=29215 width=4) (actual time=47306.135..47335.089 rows=44902 loops=1) Buffers: shared hit=2709697 read=393143 dirtied=1463 written=9210 -> Nested Loop (cost=0.00..12735226.45 rows=29215 width=4) (actual time=2.330..47129.473 rows=59118 loops=1) Buffers: shared hit=2709697 read=393143 dirtied=1463 written=9210 -> Seq Scan on part (cost=0.00..65522.00 rows=22022 width=4) (actual time=0.042..2355.013 rows=21719 loops=1) Filter: ((p_name)::text ~~ 'antique%'::text) Rows Removed by Filter: 1978281 Buffers: shared hit=9591 read=30931 written=506 -> Index Scan using pk_partsupp on partsupp (cost=0.00..575.31 rows=1 width=8) (actual time=1.434..2.057 rows=3 loops=21719) Index Cond: (ps_partkey = part.p_partkey) Filter: ((ps_availqty)::double precision > (SubPlan 1)) Rows Removed by Filter: 1 Buffers: shared hit=2700106 read=362212 dirtied=1463 written=8704 SubPlan 1 -> Aggregate (cost=140.92..140.93 rows=1 width=4) (actual time=0.487..0.487 rows=1 loops=86876) Buffers: shared hit=2630375 read=342083 dirtied=1463 written=8310 -> Index Scan using lineitem_l_partkey_l_quantity_l_shipmode_idx on lineitem (cost=0.00..140.92 rows=1 width=4) (actual time=0.308..0.483 rows=1 loops=86876) Index Cond: (l_partkey = partsupp.ps_partkey) Filter: ((l_shipdate >= '1993-01-01'::date) AND (l_shipdate < '1994-01-01'::date) AND (l_suppkey = partsupp.ps_suppkey)) Rows Removed by Filter: 29 Buffers: shared hit=2630375 read=342083 dirtied=1463 written=8310 Total runtime: 47549.705 ms (42 rows) COMMIT; COMMIT