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-21' and l_shipdate > date '1995-03-21' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2773840.83..2773840.85 rows=10 width=20) (actual time=105663.813..105663.818 rows=10 loops=1) Buffers: shared hit=640030 read=732229 dirtied=32 written=34 -> Sort (cost=2773840.83..2781823.12 rows=3192918 width=20) (actual time=105663.808..105663.812 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=640030 read=732229 dirtied=32 written=34 -> HashAggregate (cost=2672913.84..2704843.02 rows=3192918 width=20) (actual time=105569.300..105641.785 rows=113400 loops=1) Buffers: shared hit=640024 read=732229 dirtied=32 written=34 -> Hash Join (cost=631699.38..2625020.07 rows=3192918 width=20) (actual time=28916.408..104929.807 rows=300265 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=640024 read=732229 dirtied=32 written=34 -> Seq Scan on lineitem (cost=0.00..1838828.79 rows=32683392 width=12) (actual time=0.032..50785.536 rows=32214589 loops=1) Filter: (l_shipdate > '1995-03-21'::date) Rows Removed by Filter: 27830708 Buffers: shared hit=369219 read=710043 dirtied=32 written=32 -> Hash (cost=613144.04..613144.04 rows=1484427 width=12) (actual time=28914.499..28914.499 rows=1466656 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63021kB Buffers: shared hit=270805 read=22186 written=2 -> Hash Join (cost=49725.19..613144.04 rows=1484427 width=12) (actual time=1465.768..27725.311 rows=1466656 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=270805 read=22186 written=2 -> Seq Scan on orders (cost=0.00..446496.39 rows=7423869 width=16) (actual time=0.016..7739.880 rows=7334712 loops=1) Filter: (o_orderdate < '1995-03-21'::date) Rows Removed by Filter: 7680288 Buffers: shared hit=235529 read=21031 written=2 -> Hash (cost=45976.06..45976.06 rows=299930 width=4) (actual time=1465.532..1465.532 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=35276 read=1155 -> Bitmap Heap Scan on customer (cost=6948.94..45976.06 rows=299930 width=4) (actual time=207.856..1282.440 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..6873.96 rows=299930 width=0) (actual time=190.208..190.208 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 105708.002 ms (35 rows) COMMIT; COMMIT