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 = 'FURNITURE' 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=2685160.89..2685160.92 rows=10 width=20) (actual time=36241.781..36241.784 rows=10 loops=1) Buffers: shared hit=766800 read=599629 written=3746 -> Sort (cost=2685160.89..2693030.18 rows=3147716 width=20) (actual time=36241.777..36241.778 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=766800 read=599629 written=3746 -> HashAggregate (cost=2585662.72..2617139.88 rows=3147716 width=20) (actual time=36169.090..36220.204 rows=113243 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=766794 read=599629 written=3746 -> Hash Join (cost=554960.84..2538446.98 rows=3147716 width=20) (actual time=10011.650..35859.525 rows=298877 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=766794 read=599629 written=3746 -> Seq Scan on lineitem (cost=0.00..1831062.34 rows=32252438 width=12) (actual time=0.041..20057.653 rows=31932232 loops=1) Filter: (l_shipdate > '1995-03-31'::date) Rows Removed by Filter: 28052287 Buffers: shared hit=631719 read=442984 written=1 -> Hash (cost=536515.17..536515.17 rows=1475654 width=12) (actual time=9896.563..9896.563 rows=1478444 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79911kB Buffers: shared hit=135075 read=156645 written=3745 -> Hash Join (cost=49659.45..536515.17 rows=1475654 width=12) (actual time=920.332..9282.679 rows=1478444 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=135075 read=156645 written=3745 -> Seq Scan on orders (cost=0.00..444294.89 rows=7414477 width=16) (actual time=0.045..5725.360 rows=7389375 loops=1) Filter: (o_orderdate < '1995-03-31'::date) Rows Removed by Filter: 7610625 Buffers: shared hit=135073 read=120222 written=1365 -> Hash (cost=45927.76..45927.76 rows=298535 width=4) (actual time=916.069..916.069 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=2 read=36423 written=2380 -> Bitmap Heap Scan on customer (cost=6918.07..45927.76 rows=298535 width=4) (actual time=100.322..815.197 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36423 written=2380 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.44 rows=298535 width=0) (actual time=90.896..90.896 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 written=56 Planning time: 4.767 ms Execution time: 36706.258 ms (38 rows) COMMIT; COMMIT