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-25' and l_shipdate > date '1995-03-25' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2745866.23..2745866.25 rows=10 width=20) (actual time=95293.252..95293.256 rows=10 loops=1) Buffers: shared hit=622957 read=734798 dirtied=252 written=2 -> Sort (cost=2745866.23..2753815.48 rows=3179701 width=20) (actual time=95293.247..95293.249 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=622957 read=734798 dirtied=252 written=2 -> HashAggregate (cost=2645357.02..2677154.03 rows=3179701 width=20) (actual time=95189.870..95267.440 rows=113167 loops=1) Buffers: shared hit=622951 read=734798 dirtied=252 written=2 -> Hash Join (cost=626152.83..2597661.50 rows=3179701 width=20) (actual time=33083.879..94623.739 rows=298629 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=622951 read=734798 dirtied=252 written=2 -> Seq Scan on lineitem (cost=0.00..1818867.25 rows=32225176 width=12) (actual time=0.042..36454.780 rows=32115718 loops=1) Filter: (l_shipdate > '1995-03-25'::date) Rows Removed by Filter: 27929885 Buffers: shared hit=513398 read=554148 -> Hash (cost=607615.00..607615.00 rows=1483027 width=12) (actual time=33079.198..33079.198 rows=1467957 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63077kB Buffers: shared hit=109553 read=180650 dirtied=252 written=2 -> Hash Join (cost=49822.03..607615.00 rows=1483027 width=12) (actual time=1081.505..31831.706 rows=1467957 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=109553 read=180650 dirtied=252 written=2 -> Seq Scan on orders (cost=0.00..441649.60 rows=7368225 width=16) (actual time=0.025..11511.363 rows=7359435 loops=1) Filter: (o_orderdate < '1995-03-25'::date) Rows Removed by Filter: 7655565 Buffers: shared hit=74278 read=179497 dirtied=252 written=2 -> Hash (cost=46048.16..46048.16 rows=301910 width=4) (actual time=1081.154..1081.154 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35275 read=1153 -> Bitmap Heap Scan on customer (cost=6996.28..46048.16 rows=301910 width=4) (actual time=187.846..894.518 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..6920.81 rows=301910 width=0) (actual time=168.184..168.184 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 95344.574 ms (35 rows) COMMIT; COMMIT