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-18' and l_shipdate > date '1995-03-18' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2699591.85..2699591.88 rows=10 width=20) (actual time=32884.003..32884.006 rows=10 loops=1) Buffers: shared hit=708636 read=663623 dirtied=1529 written=2935 -> Sort (cost=2699591.85..2707570.35 rows=3191401 width=20) (actual time=32884.000..32884.000 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=708636 read=663623 dirtied=1529 written=2935 -> HashAggregate (cost=2598712.81..2630626.82 rows=3191401 width=20) (actual time=32816.469..32863.137 rows=114073 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=708630 read=663623 dirtied=1529 written=2935 -> Hash Join (cost=557295.70..2550841.80 rows=3191401 width=20) (actual time=8871.115..32272.353 rows=301949 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=708630 read=663623 dirtied=1529 written=2935 -> Seq Scan on lineitem (cost=0.00..1838833.75 rows=32746222 width=12) (actual time=0.056..18133.025 rows=32289408 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27755889 Buffers: shared hit=576663 read=502599 dirtied=881 written=665 -> Hash (cost=538784.77..538784.77 rows=1480875 width=12) (actual time=8863.081..8863.081 rows=1466966 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79418kB Buffers: shared hit=131967 read=161024 dirtied=648 written=2270 -> Hash Join (cost=49741.42..538784.77 rows=1480875 width=12) (actual time=775.358..8355.074 rows=1466966 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=131967 read=161024 dirtied=648 written=2270 -> Seq Scan on orders (cost=0.00..446496.39 rows=7396857 width=16) (actual time=0.022..5086.185 rows=7316009 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7698991 Buffers: shared hit=131965 read=124595 dirtied=648 written=405 -> Hash (cost=45987.60..45987.60 rows=300305 width=4) (actual time=772.859..772.859 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=1865 -> Bitmap Heap Scan on customer (cost=6955.79..45987.60 rows=300305 width=4) (actual time=76.760..680.721 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=1865 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.72 rows=300305 width=0) (actual time=67.267..67.267 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 written=148 Planning time: 3.932 ms Execution time: 32905.155 ms (38 rows) COMMIT; COMMIT