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-11' and l_shipdate > date '1995-03-11' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2699652.48..2699652.50 rows=10 width=20) (actual time=38611.109..38611.114 rows=10 loops=1) Buffers: shared hit=595061 read=777198 dirtied=917 written=1149 -> Sort (cost=2699652.48..2707623.09 rows=3188246 width=20) (actual time=38611.106..38611.107 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=595061 read=777198 dirtied=917 written=1149 -> HashAggregate (cost=2598873.17..2630755.63 rows=3188246 width=20) (actual time=38534.666..38590.409 rows=114125 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=595055 read=777198 dirtied=917 written=1149 -> Hash Join (cost=556942.43..2551049.48 rows=3188246 width=20) (actual time=11968.837..38237.868 rows=302107 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=595055 read=777198 dirtied=917 written=1149 -> Seq Scan on lineitem (cost=0.00..1838833.75 rows=32904225 width=12) (actual time=0.028..19469.401 rows=32464985 loops=1) Filter: (l_shipdate > '1995-03-11'::date) Rows Removed by Filter: 27580312 Buffers: shared hit=460449 read=618813 dirtied=917 written=888 -> Hash (cost=538538.59..538538.59 rows=1472307 width=12) (actual time=11950.934..11950.934 rows=1458176 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79040kB Buffers: shared hit=134606 read=158385 written=261 -> Hash Join (cost=49741.42..538538.59 rows=1472307 width=12) (actual time=920.181..11320.070 rows=1458176 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=134606 read=158385 written=261 -> Seq Scan on orders (cost=0.00..446496.39 rows=7354057 width=16) (actual time=0.029..5908.797 rows=7272073 loops=1) Filter: (o_orderdate < '1995-03-11'::date) Rows Removed by Filter: 7742927 Buffers: shared hit=134604 read=121956 written=215 -> Hash (cost=45987.60..45987.60 rows=300305 width=4) (actual time=915.652..915.652 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=46 -> Bitmap Heap Scan on customer (cost=6955.79..45987.60 rows=300305 width=4) (actual time=81.459..791.141 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=46 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.72 rows=300305 width=0) (actual time=71.696..71.696 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 4.366 ms Execution time: 38637.347 ms (38 rows) COMMIT; COMMIT