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-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2748351.44..2748351.46 rows=10 width=20) (actual time=93847.189..93847.195 rows=10 loops=1) Buffers: shared hit=923788 read=436593 dirtied=252 written=2 -> Sort (cost=2748351.44..2756237.07 rows=3154254 width=20) (actual time=93847.185..93847.189 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=923788 read=436593 dirtied=252 written=2 -> HashAggregate (cost=2648646.60..2680189.14 rows=3154254 width=20) (actual time=93713.462..93811.875 rows=113137 loops=1) Buffers: shared hit=923782 read=436593 dirtied=252 written=2 -> Hash Join (cost=624880.77..2601332.79 rows=3154254 width=20) (actual time=30591.316..92844.174 rows=298880 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=923782 read=436593 dirtied=252 written=2 -> Seq Scan on lineitem (cost=0.00..1822480.27 rows=32647787 width=12) (actual time=0.100..36123.747 rows=32565911 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27479392 Buffers: shared hit=665227 read=404439 written=2 -> Hash (cost=606693.15..606693.15 rows=1455010 width=12) (actual time=30589.169..30589.169 rows=1445611 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62117kB Buffers: shared hit=258555 read=32154 dirtied=252 -> Hash Join (cost=49752.35..606693.15 rows=1455010 width=12) (actual time=1807.719..29617.259 rows=1445611 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=258555 read=32154 dirtied=252 -> Seq Scan on orders (cost=0.00..442530.20 rows=7262582 width=16) (actual time=0.019..8531.073 rows=7246928 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7768072 Buffers: shared hit=238802 read=15479 dirtied=252 -> Hash (cost=45995.91..45995.91 rows=300515 width=4) (actual time=1807.484..1807.484 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=19753 read=16675 -> Bitmap Heap Scan on customer (cost=6961.47..45995.91 rows=300515 width=4) (actual time=174.246..1626.343 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=19753 read=16675 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6886.34 rows=300515 width=0) (actual time=163.437..163.437 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 93906.253 ms (35 rows) COMMIT; COMMIT