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-31' and l_shipdate > date '1995-03-31' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2694135.48..2694135.51 rows=10 width=20) (actual time=32680.090..32680.095 rows=10 loops=1) Buffers: shared hit=727077 read=642530 dirtied=103 written=1773 -> Sort (cost=2694135.48..2702107.51 rows=3188811 width=20) (actual time=32680.086..32680.087 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=727077 read=642530 dirtied=103 written=1773 -> HashAggregate (cost=2593338.31..2625226.42 rows=3188811 width=20) (actual time=32557.913..32659.003 rows=113021 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=727071 read=642530 dirtied=103 written=1773 -> Hash Join (cost=556917.21..2545506.15 rows=3188811 width=20) (actual time=8490.682..32294.856 rows=297911 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=727071 read=642530 dirtied=103 written=1773 -> Seq Scan on lineitem (cost=0.00..1835182.91 rows=32404777 width=12) (actual time=0.069..18309.057 rows=31932887 loops=1) Filter: (l_shipdate > '1995-03-31'::date) Rows Removed by Filter: 28051939 Buffers: shared hit=484338 read=592782 written=4 -> Hash (cost=538263.27..538263.27 rows=1492315 width=12) (actual time=8478.506..8478.506 rows=1474128 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79726kB Buffers: shared hit=242733 read=49748 dirtied=103 written=1769 -> Hash Join (cost=49712.62..538263.27 rows=1492315 width=12) (actual time=481.368..7966.903 rows=1474128 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=242733 read=49748 dirtied=103 written=1769 -> Seq Scan on orders (cost=0.00..445615.79 rows=7469791 width=16) (actual time=0.034..4948.669 rows=7389217 loops=1) Filter: (o_orderdate < '1995-03-31'::date) Rows Removed by Filter: 7610783 Buffers: shared hit=207458 read=48596 dirtied=103 written=1769 -> Hash (cost=45966.74..45966.74 rows=299670 width=4) (actual time=477.744..477.744 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6942.87..45966.74 rows=299670 width=4) (actual time=75.643..388.139 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6867.95 rows=299670 width=0) (actual time=66.260..66.260 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 3.691 ms Execution time: 32713.049 ms (38 rows) COMMIT; COMMIT