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-14' and l_shipdate > date '1995-03-14' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2779299.88..2779299.90 rows=10 width=20) (actual time=69353.506..69353.511 rows=10 loops=1) Buffers: shared hit=801024 read=573861 dirtied=887 written=891 -> Sort (cost=2779299.88..2787291.79 rows=3196766 width=20) (actual time=69353.501..69353.504 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=801024 read=573861 dirtied=887 written=891 -> HashAggregate (cost=2678251.25..2710218.91 rows=3196766 width=20) (actual time=69268.733..69334.591 rows=113427 loops=1) Buffers: shared hit=801018 read=573861 dirtied=887 written=891 -> Hash Join (cost=632543.18..2630299.76 rows=3196766 width=20) (actual time=25713.610..68882.082 rows=299923 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=801018 read=573861 dirtied=887 written=891 -> Seq Scan on lineitem (cost=0.00..1842436.95 rows=32893858 width=12) (actual time=0.056..23364.319 rows=32390406 loops=1) Filter: (l_shipdate > '1995-03-14'::date) Rows Removed by Filter: 27654387 Buffers: shared hit=514219 read=567163 dirtied=887 written=887 -> Hash (cost=614047.95..614047.95 rows=1479619 width=12) (actual time=25711.369..25711.369 rows=1457792 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62640kB Buffers: shared hit=286799 read=6698 written=4 -> Hash Join (cost=49660.32..614047.95 rows=1479619 width=12) (actual time=730.122..24908.697 rows=1457792 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=286799 read=6698 written=4 -> Seq Scan on orders (cost=0.00..447376.99 rows=7433778 width=16) (actual time=0.034..6491.983 rows=7290640 loops=1) Filter: (o_orderdate < '1995-03-14'::date) Rows Removed by Filter: 7724360 Buffers: shared hit=251523 read=5543 written=4 -> Hash (cost=45928.32..45928.32 rows=298560 width=4) (actual time=729.812..729.812 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=137.432..588.053 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=118.112..118.112 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 69390.675 ms (35 rows) COMMIT; COMMIT