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 = 'MACHINERY' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-10' and l_shipdate > date '1995-03-10' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2741311.37..2741311.40 rows=10 width=20) (actual time=37796.306..37796.318 rows=10 loops=1) Buffers: shared hit=838787 read=517647 -> Sort (cost=2741311.37..2749184.83 rows=3149382 width=20) (actual time=37796.293..37796.295 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=838787 read=517647 -> HashAggregate (cost=2641760.54..2673254.36 rows=3149382 width=20) (actual time=37741.015..37777.726 rows=113490 loops=1) Buffers: shared hit=838781 read=517647 -> Hash Join (cost=624006.90..2594519.81 rows=3149382 width=20) (actual time=10875.353..37523.595 rows=299681 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=838781 read=517647 -> Seq Scan on lineitem (cost=0.00..1817038.70 rows=32528103 width=12) (actual time=0.037..18119.061 rows=32491428 loops=1) Filter: (l_shipdate > '1995-03-10'::date) Rows Removed by Filter: 27554241 Buffers: shared hit=549983 read=516492 -> Hash (cost=605834.95..605834.95 rows=1453756 width=12) (actual time=10872.748..10872.748 rows=1452519 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62413kB Buffers: shared hit=288798 read=1155 -> Hash Join (cost=49660.32..605834.95 rows=1453756 width=12) (actual time=438.980..10420.296 rows=1452519 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288798 read=1155 -> Seq Scan on orders (cost=0.00..441209.30 rows=7303838 width=16) (actual time=0.014..4679.176 rows=7265540 loops=1) Filter: (o_orderdate < '1995-03-10'::date) Rows Removed by Filter: 7749460 Buffers: shared hit=253522 -> Hash (cost=45928.32..45928.32 rows=298560 width=4) (actual time=438.703..438.703 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=35276 read=1155 -> Bitmap Heap Scan on customer (cost=6918.32..45928.32 rows=298560 width=4) (actual time=67.709..370.942 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=35276 read=1155 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.68 rows=298560 width=0) (actual time=59.029..59.029 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 37826.240 ms (35 rows) COMMIT; COMMIT