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-26' and l_shipdate > date '1995-03-26' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2760731.66..2760731.69 rows=10 width=20) (actual time=140471.961..140471.966 rows=10 loops=1) Buffers: shared hit=717631 read=648899 written=5358 -> Sort (cost=2760731.66..2768647.95 rows=3166515 width=20) (actual time=140471.958..140471.959 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=717631 read=648899 written=5358 -> HashAggregate (cost=2660639.26..2692304.41 rows=3166515 width=20) (actual time=140369.006..140448.187 rows=113926 loops=1) Buffers: shared hit=717625 read=648899 written=5358 -> Hash Join (cost=629329.09..2613141.54 rows=3166515 width=20) (actual time=39833.180..139563.820 rows=301439 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=717625 read=648899 written=5358 -> Seq Scan on lineitem (cost=0.00..1831215.49 rows=32248483 width=12) (actual time=0.093..72500.722 rows=32057241 loops=1) Filter: (l_shipdate > '1995-03-26'::date) Rows Removed by Filter: 27927278 Buffers: shared hit=469986 read=604811 -> Hash (cost=610770.98..610770.98 rows=1484649 width=12) (actual time=39830.787..39830.787 rows=1475429 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63398kB Buffers: shared hit=247639 read=44088 written=5358 -> Hash Join (cost=49758.64..610770.98 rows=1484649 width=12) (actual time=3619.892..38805.984 rows=1475429 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=247639 read=44088 written=5358 -> Seq Scan on orders (cost=0.00..444294.89 rows=7408797 width=16) (actual time=0.018..12939.120 rows=7358457 loops=1) Filter: (o_orderdate < '1995-03-26'::date) Rows Removed by Filter: 7641543 Buffers: shared hit=247637 read=7658 written=228 -> Hash (cost=46001.33..46001.33 rows=300585 width=4) (actual time=3619.519..3619.519 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=2 read=36430 written=5130 -> Bitmap Heap Scan on customer (cost=6966.01..46001.33 rows=300585 width=4) (actual time=191.466..3406.864 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=2 read=36430 written=5130 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6890.87 rows=300585 width=0) (actual time=175.964..175.964 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 written=93 Total runtime: 140527.944 ms (35 rows) COMMIT; COMMIT