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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-13' and l_shipdate > date '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2695984.90..2695984.93 rows=10 width=20) (actual time=34516.644..34516.649 rows=10 loops=1) Buffers: shared hit=706610 read=664322 written=106 -> Sort (cost=2695984.90..2703916.28 rows=3172552 width=20) (actual time=34516.640..34516.642 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=706610 read=664322 written=106 -> HashAggregate (cost=2595701.67..2627427.19 rows=3172552 width=20) (actual time=34439.422..34494.746 rows=114142 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=706604 read=664322 written=106 -> Hash Join (cost=556303.95..2548113.39 rows=3172552 width=20) (actual time=9356.717..34169.631 rows=302359 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=706604 read=664322 written=106 -> Seq Scan on lineitem (cost=0.00..1837000.04 rows=32822370 width=12) (actual time=0.106..19127.336 rows=32415187 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27629807 Buffers: shared hit=533993 read=544195 -> Hash (cost=537963.14..537963.14 rows=1467265 width=12) (actual time=9340.161..9340.161 rows=1460739 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79151kB Buffers: shared hit=172611 read=120127 written=106 -> Hash Join (cost=49736.01..537963.14 rows=1467265 width=12) (actual time=904.125..8753.937 rows=1460739 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=172611 read=120127 written=106 -> Seq Scan on orders (cost=0.00..446056.09 rows=7332903 width=16) (actual time=0.035..5228.467 rows=7284464 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7730536 Buffers: shared hit=172608 read=83699 written=74 -> Hash (cost=45984.26..45984.26 rows=300140 width=4) (actual time=899.921..899.921 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=3 read=36428 written=32 -> Bitmap Heap Scan on customer (cost=6954.51..45984.26 rows=300140 width=4) (actual time=116.635..798.697 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=3 read=36428 written=32 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.48 rows=300140 width=0) (actual time=104.143..104.143 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 written=2 Planning time: 6.194 ms Execution time: 34548.809 ms (38 rows) COMMIT; COMMIT