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-29' and l_shipdate > date '1995-03-29' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2778278.37..2778278.40 rows=10 width=20) (actual time=85212.590..85212.596 rows=10 loops=1) Buffers: shared hit=792708 read=582177 dirtied=253 written=618 -> Sort (cost=2778278.37..2786251.78 rows=3189364 width=20) (actual time=85212.586..85212.589 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=792708 read=582177 dirtied=253 written=618 -> HashAggregate (cost=2677463.72..2709357.36 rows=3189364 width=20) (actual time=85124.762..85191.933 rows=113560 loops=1) Buffers: shared hit=792702 read=582177 dirtied=253 written=618 -> Hash Join (cost=633638.39..2629623.26 rows=3189364 width=20) (actual time=28838.618..84610.165 rows=300634 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=792702 read=582177 dirtied=253 written=618 -> Seq Scan on lineitem (cost=0.00..1842441.31 rows=32439980 width=12) (actual time=0.038..31975.396 rows=32015003 loops=1) Filter: (l_shipdate > '1995-03-29'::date) Rows Removed by Filter: 28029790 Buffers: shared hit=516444 read=564938 -> Hash (cost=614927.80..614927.80 rows=1496847 width=12) (actual time=28836.580..28836.580 rows=1476665 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63451kB Buffers: shared hit=276258 read=17239 dirtied=253 written=618 -> Hash Join (cost=49737.54..614927.80 rows=1496847 width=12) (actual time=841.619..27240.225 rows=1476665 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=276258 read=17239 dirtied=253 written=618 -> Seq Scan on orders (cost=0.00..447376.99 rows=7479622 width=16) (actual time=0.018..7562.565 rows=7384189 loops=1) Filter: (o_orderdate < '1995-03-29'::date) Rows Removed by Filter: 7630811 Buffers: shared hit=241084 read=15982 dirtied=253 written=190 -> Hash (cost=45985.23..45985.23 rows=300185 width=4) (actual time=841.394..841.394 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=35174 read=1257 written=428 -> Bitmap Heap Scan on customer (cost=6954.91..45985.23 rows=300185 width=4) (actual time=159.586..675.082 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=35174 read=1257 written=428 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.87 rows=300185 width=0) (actual time=143.242..143.242 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 written=409 Total runtime: 85271.850 ms (35 rows) COMMIT; COMMIT