BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-03' and l_shipdate > date '1995-03-03' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2672387.45..2672387.47 rows=10 width=20) (actual time=34090.916..34090.921 rows=10 loops=1) Buffers: shared hit=822768 read=536001 written=1479 -> Sort (cost=2672387.45..2680248.57 rows=3144449 width=20) (actual time=34090.913..34090.914 rows=10 loops=1) Sort Key: (sum((lineitem.l_extendedprice * (1::double precision - lineitem.l_discount)))), orders.o_orderdate Sort Method: top-N heapsort Memory: 25kB Buffers: shared hit=822768 read=536001 written=1479 -> HashAggregate (cost=2572992.54..2604437.03 rows=3144449 width=20) (actual time=34018.442..34070.502 rows=112936 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=822762 read=536001 written=1479 -> Hash Join (cost=550893.66..2525825.81 rows=3144449 width=20) (actual time=8727.157..33751.428 rows=298031 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=822762 read=536001 written=1479 -> Seq Scan on lineitem (cost=0.00..1820587.88 rows=32773277 width=12) (actual time=0.051..19054.031 rows=32633826 loops=1) Filter: (l_shipdate > '1995-03-03'::date) Rows Removed by Filter: 27351726 Buffers: shared hit=589762 read=478799 -> Hash (cost=532867.93..532867.93 rows=1442058 width=12) (actual time=8710.239..8710.239 rows=1439126 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78222kB Buffers: shared hit=233000 read=57202 written=1479 -> Hash Join (cost=49696.83..532867.93 rows=1442058 width=12) (actual time=834.253..8169.751 rows=1439126 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=233000 read=57202 written=1479 -> Seq Scan on orders (cost=0.00..441649.60 rows=7226912 width=16) (actual time=0.026..4881.406 rows=7214408 loops=1) Filter: (o_orderdate < '1995-03-03'::date) Rows Removed by Filter: 7785592 Buffers: shared hit=232998 read=20777 written=15 -> Hash (cost=45955.46..45955.46 rows=299310 width=4) (actual time=831.105..831.105 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 written=1464 -> Bitmap Heap Scan on customer (cost=6936.08..45955.46 rows=299310 width=4) (actual time=75.901..736.515 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=1464 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6861.25 rows=299310 width=0) (actual time=66.742..66.742 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 written=40 Planning time: 4.126 ms Execution time: 34135.771 ms (38 rows) COMMIT; COMMIT