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 = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-10' and l_shipdate > date '1995-03-10' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2740536.77..2740536.80 rows=10 width=20) (actual time=48218.022..48218.026 rows=10 loops=1) Buffers: shared hit=839070 read=517361 -> Sort (cost=2740536.77..2748404.24 rows=3146987 width=20) (actual time=48217.966..48217.969 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=839070 read=517361 -> HashAggregate (cost=2641061.64..2672531.51 rows=3146987 width=20) (actual time=48139.844..48199.893 rows=113132 loops=1) Buffers: shared hit=839064 read=517361 -> Hash Join (cost=623572.88..2593856.84 rows=3146987 width=20) (actual time=16199.165..47898.363 rows=298677 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=839064 read=517361 -> Seq Scan on lineitem (cost=0.00..1817043.50 rows=32472156 width=12) (actual time=0.033..17868.281 rows=32491428 loops=1) Filter: (l_shipdate > '1995-03-10'::date) Rows Removed by Filter: 27554241 Buffers: shared hit=550267 read=516208 -> Hash (cost=605383.47..605383.47 rows=1455153 width=12) (actual time=16196.894..16196.894 rows=1449327 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62276kB Buffers: shared hit=288797 read=1153 -> Hash Join (cost=49752.35..605383.47 rows=1455153 width=12) (actual time=410.901..15726.636 rows=1449327 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288797 read=1153 -> Seq Scan on orders (cost=0.00..441209.30 rows=7263294 width=16) (actual time=0.014..4684.259 rows=7265540 loops=1) Filter: (o_orderdate < '1995-03-10'::date) Rows Removed by Filter: 7749460 Buffers: shared hit=253522 -> Hash (cost=45995.91..45995.91 rows=300515 width=4) (actual time=410.697..410.697 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35275 read=1153 -> Bitmap Heap Scan on customer (cost=6961.47..45995.91 rows=300515 width=4) (actual time=71.430..342.290 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=35275 read=1153 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6886.34 rows=300515 width=0) (actual time=62.994..62.994 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 48269.108 ms (35 rows) COMMIT; COMMIT