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-24' and l_shipdate > date '1995-03-24' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2780314.49..2780314.51 rows=10 width=20) (actual time=108656.662..108656.669 rows=10 loops=1) Buffers: shared hit=1015759 read=360445 dirtied=31 written=22 -> Sort (cost=2780314.49..2788283.06 rows=3187429 width=20) (actual time=108656.657..108656.661 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=1015759 read=360445 dirtied=31 written=22 -> HashAggregate (cost=2679561.00..2711435.29 rows=3187429 width=20) (actual time=108563.065..108635.757 rows=114029 loops=1) Buffers: shared hit=1015753 read=360445 dirtied=31 written=22 -> Hash Join (cost=633649.15..2631749.57 rows=3187429 width=20) (actual time=40882.221..108017.334 rows=301704 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1015753 read=360445 dirtied=31 written=22 -> Seq Scan on lineitem (cost=0.00..1844247.69 rows=32527584 width=12) (actual time=0.039..41843.498 rows=32139912 loops=1) Filter: (l_shipdate > '1995-03-24'::date) Rows Removed by Filter: 27904704 Buffers: shared hit=757149 read=325297 -> Hash (cost=614981.85..614981.85 rows=1493384 width=12) (actual time=40880.277..40880.277 rows=1474438 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63355kB Buffers: shared hit=258604 read=35148 dirtied=31 written=22 -> Hash Join (cost=49758.64..614981.85 rows=1493384 width=12) (actual time=1898.674..39579.771 rows=1474438 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=258604 read=35148 dirtied=31 written=22 -> Seq Scan on orders (cost=0.00..447819.04 rows=7452388 width=16) (actual time=0.020..16276.281 rows=7353220 loops=1) Filter: (o_orderdate < '1995-03-24'::date) Rows Removed by Filter: 7661780 Buffers: shared hit=225374 read=31946 dirtied=31 written=22 -> Hash (cost=46001.33..46001.33 rows=300585 width=4) (actual time=1898.430..1898.430 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=33230 read=3202 -> Bitmap Heap Scan on customer (cost=6966.01..46001.33 rows=300585 width=4) (actual time=222.574..1725.759 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=33230 read=3202 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6890.87 rows=300585 width=0) (actual time=206.695..206.695 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 108701.047 ms (35 rows) COMMIT; COMMIT