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-31' and l_shipdate > date '1995-03-31' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2743525.12..2743525.15 rows=10 width=20) (actual time=79342.550..79342.556 rows=10 loops=1) Buffers: shared hit=989007 read=368748 dirtied=252 written=8 -> Sort (cost=2743525.12..2751401.65 rows=3150609 width=20) (actual time=79342.545..79342.548 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=989007 read=368748 dirtied=252 written=8 -> HashAggregate (cost=2643935.50..2675441.59 rows=3150609 width=20) (actual time=79236.294..79320.663 rows=113175 loops=1) Buffers: shared hit=989001 read=368748 dirtied=252 written=8 -> Hash Join (cost=626428.84..2596676.37 rows=3150609 width=20) (actual time=27199.981..78774.600 rows=298465 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=989001 read=368748 dirtied=252 written=8 -> Seq Scan on lineitem (cost=0.00..1818867.75 rows=31966316 width=12) (actual time=0.053..28327.781 rows=31965617 loops=1) Filter: (l_shipdate > '1995-03-31'::date) Rows Removed by Filter: 28079986 Buffers: shared hit=773903 read=293643 -> Hash (cost=607911.87..607911.87 rows=1481358 width=12) (actual time=27195.503..27195.503 rows=1475483 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63400kB Buffers: shared hit=215098 read=75105 dirtied=252 written=8 -> Hash Join (cost=49749.40..607911.87 rows=1481358 width=12) (actual time=656.579..25755.407 rows=1475483 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=215098 read=75105 dirtied=252 written=8 -> Seq Scan on orders (cost=0.00..441649.60 rows=7396312 width=16) (actual time=0.022..6843.492 rows=7396516 loops=1) Filter: (o_orderdate < '1995-03-31'::date) Rows Removed by Filter: 7618484 Buffers: shared hit=179823 read=73952 dirtied=252 written=8 -> Hash (cost=45994.09..45994.09 rows=300425 width=4) (actual time=656.319..656.319 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35275 read=1153 -> Bitmap Heap Scan on customer (cost=6960.77..45994.09 rows=300425 width=4) (actual time=113.166..543.346 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..6885.67 rows=300425 width=0) (actual time=101.088..101.088 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 79406.639 ms (35 rows) COMMIT; COMMIT