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 = 'FURNITURE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2668262.52..2668262.55 rows=10 width=20) (actual time=38504.292..38504.297 rows=10 loops=1) Buffers: shared hit=788931 read=567497 dirtied=24 written=1780 -> Sort (cost=2668262.52..2676132.41 rows=3147956 width=20) (actual time=38504.286..38504.287 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=788931 read=567497 dirtied=24 written=1780 -> HashAggregate (cost=2568756.77..2600236.33 rows=3147956 width=20) (actual time=38423.611..38483.472 rows=113461 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=788925 read=567497 dirtied=24 written=1780 -> Hash Join (cost=550715.60..2521537.43 rows=3147956 width=20) (actual time=12435.446..38134.112 rows=298593 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=788925 read=567497 dirtied=24 written=1780 -> Seq Scan on lineitem (cost=0.00..1817047.41 rows=32611961 width=12) (actual time=0.092..18521.374 rows=32533369 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27451960 Buffers: shared hit=615019 read=451456 written=5 -> Hash (cost=532598.59..532598.59 rows=1449361 width=12) (actual time=12422.689..12422.689 rows=1448442 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78622kB Buffers: shared hit=173906 read=116041 dirtied=24 written=1775 -> Hash Join (cost=49737.81..532598.59 rows=1449361 width=12) (actual time=1081.196..11740.721 rows=1448442 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=173906 read=116041 dirtied=24 written=1775 -> Seq Scan on orders (cost=0.00..441209.30 rows=7242097 width=16) (actual time=0.037..6005.053 rows=7239643 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7760357 Buffers: shared hit=139891 read=113631 dirtied=24 written=1775 -> Hash (cost=45985.38..45985.38 rows=300195 width=4) (actual time=1077.621..1077.621 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=34015 read=2410 -> Bitmap Heap Scan on customer (cost=6954.94..45985.38 rows=300195 width=4) (actual time=154.201..922.360 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=34015 read=2410 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.89 rows=300195 width=0) (actual time=134.983..134.983 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 3.117 ms Execution time: 38527.671 ms (38 rows) COMMIT; COMMIT