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-08' and l_shipdate > date '1995-03-08' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2749389.78..2749389.81 rows=10 width=20) (actual time=77057.582..77057.587 rows=10 loops=1) Buffers: shared hit=649908 read=710476 dirtied=319 written=19 -> Sort (cost=2749389.78..2757287.81 rows=3159212 width=20) (actual time=77057.576..77057.580 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=649908 read=710476 dirtied=319 written=19 -> HashAggregate (cost=2649528.22..2681120.34 rows=3159212 width=20) (actual time=76956.738..77035.876 rows=113501 loops=1) Buffers: shared hit=649902 read=710476 dirtied=319 written=19 -> Hash Join (cost=625543.86..2602140.04 rows=3159212 width=20) (actual time=27169.112..76490.985 rows=299803 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=649902 read=710476 dirtied=319 written=19 -> Seq Scan on lineitem (cost=0.00..1822475.46 rows=32674294 width=12) (actual time=0.053..27524.277 rows=32541017 loops=1) Filter: (l_shipdate > '1995-03-08'::date) Rows Removed by Filter: 27504286 Buffers: shared hit=479815 read=589851 -> Hash (cost=607342.42..607342.42 rows=1456115 width=12) (actual time=27166.463..27166.463 rows=1450181 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62313kB Buffers: shared hit=170087 read=120625 dirtied=319 written=19 -> Hash Join (cost=49660.32..607342.42 rows=1456115 width=12) (actual time=1201.083..25909.532 rows=1450181 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=170087 read=120625 dirtied=319 written=19 -> Seq Scan on orders (cost=0.00..442530.20 rows=7315691 width=16) (actual time=0.028..7002.972 rows=7253318 loops=1) Filter: (o_orderdate < '1995-03-08'::date) Rows Removed by Filter: 7761682 Buffers: shared hit=170083 read=84198 dirtied=319 written=19 -> Hash (cost=45928.32..45928.32 rows=298560 width=4) (actual time=1200.746..1200.746 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=4 read=36427 -> Bitmap Heap Scan on customer (cost=6918.32..45928.32 rows=298560 width=4) (actual time=105.122..1037.013 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=4 read=36427 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.68 rows=298560 width=0) (actual time=95.349..95.349 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 77107.293 ms (35 rows) COMMIT; COMMIT