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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2670572.68..2670572.70 rows=10 width=20) (actual time=32702.595..32702.599 rows=10 loops=1) Buffers: shared hit=766068 read=591690 dirtied=1 written=1 -> Sort (cost=2670572.68..2678439.62 rows=3146776 width=20) (actual time=32702.591..32702.593 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=766068 read=591690 dirtied=1 written=1 -> HashAggregate (cost=2571104.22..2602571.98 rows=3146776 width=20) (actual time=32635.349..32682.704 rows=114055 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=766062 read=591690 dirtied=1 written=1 -> Hash Join (cost=551131.03..2523902.58 rows=3146776 width=20) (actual time=9395.954..32227.059 rows=301858 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=766062 read=591690 dirtied=1 written=1 -> Seq Scan on lineitem (cost=0.00..1818872.36 rows=32648380 width=12) (actual time=0.039..16572.624 rows=32566070 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27479533 Buffers: shared hit=477259 read=590287 dirtied=1 written=1 -> Hash (cost=533022.96..533022.96 rows=1448646 width=12) (actual time=9367.116..9367.116 rows=1453282 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78830kB Buffers: shared hit=288803 read=1403 -> Hash Join (cost=49735.19..533022.96 rows=1448646 width=12) (actual time=473.992..8776.747 rows=1453282 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288803 read=1403 -> Seq Scan on orders (cost=0.00..441649.60 rows=7240454 width=16) (actual time=0.039..4310.845 rows=7246881 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7768119 Buffers: shared hit=253537 read=238 -> Hash (cost=45983.76..45983.76 rows=300115 width=4) (actual time=469.034..469.034 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=35266 read=1165 -> Bitmap Heap Scan on customer (cost=6954.32..45983.76 rows=300115 width=4) (actual time=88.421..365.631 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=35266 read=1165 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.29 rows=300115 width=0) (actual time=74.597..74.597 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 2.976 ms Execution time: 32737.529 ms (38 rows) COMMIT; COMMIT