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-22' and l_shipdate > date '1995-03-22' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2748661.08..2748661.11 rows=10 width=20) (actual time=82953.338..82953.344 rows=10 loops=1) Buffers: shared hit=712111 read=648273 dirtied=355 written=1 -> Sort (cost=2748661.08..2756548.64 rows=3155021 width=20) (actual time=82953.333..82953.337 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=712111 read=648273 dirtied=355 written=1 -> HashAggregate (cost=2648932.00..2680482.21 rows=3155021 width=20) (actual time=82824.410..82919.413 rows=113469 loops=1) Buffers: shared hit=712105 read=648273 dirtied=355 written=1 -> Hash Join (cost=626584.18..2601606.69 rows=3155021 width=20) (actual time=25503.024..82305.091 rows=300272 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=712105 read=648273 dirtied=355 written=1 -> Seq Scan on lineitem (cost=0.00..1822479.77 rows=32264672 width=12) (actual time=0.051..31752.075 rows=32190234 loops=1) Filter: (l_shipdate > '1995-03-22'::date) Rows Removed by Filter: 27855069 Buffers: shared hit=434783 read=634883 dirtied=1 written=1 -> Hash (cost=608176.12..608176.12 rows=1472645 width=12) (actual time=25500.708..25500.708 rows=1467800 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63070kB Buffers: shared hit=277322 read=13390 dirtied=354 -> Hash Join (cost=49737.54..608176.12 rows=1472645 width=12) (actual time=787.347..24558.554 rows=1467800 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=277322 read=13390 dirtied=354 -> Seq Scan on orders (cost=0.00..442530.20 rows=7358686 width=16) (actual time=0.025..6530.553 rows=7340892 loops=1) Filter: (o_orderdate < '1995-03-22'::date) Rows Removed by Filter: 7674108 Buffers: shared hit=242050 read=12231 dirtied=354 -> Hash (cost=45985.23..45985.23 rows=300185 width=4) (actual time=787.030..787.030 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=35272 read=1159 -> Bitmap Heap Scan on customer (cost=6954.91..45985.23 rows=300185 width=4) (actual time=125.731..640.340 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=35272 read=1159 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.87 rows=300185 width=0) (actual time=112.757..112.757 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 83021.887 ms (35 rows) COMMIT; COMMIT