QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=3837431.25..3837431.25 rows=1 width=51) (actual time=91439.268..91439.269 rows=1 loops=1) -> Sort (cost=3837431.25..3837436.25 rows=2000 width=51) (actual time=91439.266..91439.266 rows=1 loops=1) Sort Key: supplier.s_name Sort Method: top-N heapsort Memory: 25kB -> Nested Loop Semi Join (cost=2868332.99..3837421.25 rows=2000 width=51) (actual time=59758.506..91436.121 rows=1771 loops=1) Join Filter: (supplier.s_suppkey = lineitem.l_suppkey) Rows Removed by Join Filter: 177272721 -> Nested Loop (cost=79.29..2535.58 rows=4000 width=55) (actual time=0.766..15.081 rows=3991 loops=1) -> Seq Scan on nation (cost=0.00..1.31 rows=1 width=4) (actual time=0.013..0.021 rows=1 loops=1) Filter: (n_name = 'PERU'::bpchar) Rows Removed by Filter: 24 -> Bitmap Heap Scan on supplier (cost=79.29..2494.27 rows=4000 width=63) (actual time=0.750..14.045 rows=3991 loops=1) Recheck Cond: (s_nationkey = nation.n_nationkey) Heap Blocks: exact=1907 -> Bitmap Index Scan on idx_supplier_nation_key (cost=0.00..78.29 rows=4000 width=0) (actual time=0.521..0.521 rows=3991 loops=1) Index Cond: (s_nationkey = nation.n_nationkey) -> Materialize (cost=2868253.69..3815686.46 rows=320 width=16) (actual time=4.030..17.741 rows=44419 loops=3991) -> Nested Loop Semi Join (cost=2868253.69..3815684.86 rows=320 width=16) (actual time=16084.877..59729.809 rows=58901 loops=1) Join Filter: (lineitem.l_partkey = part.p_partkey) -> Merge Join (cost=2868253.27..3815530.23 rows=320 width=32) (actual time=16083.345..37027.842 rows=5431247 loops=1) Merge Cond: ((lineitem.l_partkey = partsupp.ps_partkey) AND (lineitem.l_suppkey = partsupp.ps_suppkey)) Join Filter: ((partsupp.ps_availqty)::numeric > ((0.5 * sum(lineitem.l_quantity)))) Rows Removed by Join Filter: 11504 -> GroupAggregate (cost=2868252.83..3035121.11 rows=4895341 width=48) (actual time=16083.240..27824.466 rows=5442751 loops=1) Group Key: lineitem.l_partkey, lineitem.l_suppkey -> Sort (cost=2868252.83..2891612.37 rows=9343816 width=21) (actual time=16083.206..19212.741 rows=9109641 loops=1) Sort Key: lineitem.l_partkey, lineitem.l_suppkey Sort Method: external merge Disk: 275960kB -> Bitmap Heap Scan on lineitem (cost=239686.68..1594823.92 rows=9343816 width=21) (actual time=2293.653..8887.630 rows=9109641 loops=1) Recheck Cond: ((l_shipdate >= '1993-01-01'::date) AND (l_shipdate < '1994-01-01 00:00:00'::timestamp without time zone)) Heap Blocks: exact=1114490 -> Bitmap Index Scan on idx_lineitem_shipdate (cost=0.00..237350.73 rows=9343816 width=0) (actual time=1814.430..1814.430 rows=9109641 loops=1) Index Cond: ((l_shipdate >= '1993-01-01'::date) AND (l_shipdate < '1994-01-01 00:00:00'::timestamp without time zone)) -> Index Scan using partsupp_pkey on partsupp (cost=0.43..666964.62 rows=8000000 width=20) (actual time=0.091..3023.836 rows=8000000 loops=1) -> Index Scan using part_pkey on part (cost=0.43..0.47 rows=1 width=4) (actual time=0.004..0.004 rows=0 loops=5431247) Index Cond: (p_partkey = partsupp.ps_partkey) Filter: ((p_name)::text ~~ 'snow%'::text) Rows Removed by Filter: 1 Planning time: 2.092 ms Execution time: 91467.442 ms (40 rows) s_name | s_address ---------------------------+-------------------------------- Supplier#000000008 | 9Sq4bBH2FQEmaFOocY45sRTxo6yuoG (1 row)