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-24' and l_shipdate > date '1995-03-24' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2688670.85..2688670.88 rows=10 width=20) (actual time=30019.316..30019.320 rows=10 loops=1) Buffers: shared hit=706748 read=660209 -> Sort (cost=2688670.85..2696616.09 rows=3178096 width=20) (actual time=30019.312..30019.313 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=706748 read=660209 -> HashAggregate (cost=2588212.38..2619993.34 rows=3178096 width=20) (actual time=29960.717..30000.300 rows=113020 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=706742 read=660209 -> Hash Join (cost=555606.44..2540540.94 rows=3178096 width=20) (actual time=8015.367..29727.248 rows=298217 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=706742 read=660209 -> Seq Scan on lineitem (cost=0.00..1831531.51 rows=32432541 width=12) (actual time=0.065..16798.034 rows=32106780 loops=1) Filter: (l_shipdate > '1995-03-24'::date) Rows Removed by Filter: 27877142 Buffers: shared hit=548516 read=526460 -> Hash (cost=537067.80..537067.80 rows=1483091 width=12) (actual time=8003.740..8003.740 rows=1465377 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79350kB Buffers: shared hit=158226 read=133749 -> Hash Join (cost=49764.48..537067.80 rows=1483091 width=12) (actual time=697.912..7465.565 rows=1465377 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=158226 read=133749 -> Seq Scan on orders (cost=0.00..444735.19 rows=7396593 width=16) (actual time=0.030..4563.852 rows=7346132 loops=1) Filter: (o_orderdate < '1995-03-24'::date) Rows Removed by Filter: 7653868 Buffers: shared hit=158224 read=97324 -> Hash (cost=46004.92..46004.92 rows=300765 width=4) (actual time=695.124..695.124 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 -> Bitmap Heap Scan on customer (cost=6967.36..46004.92 rows=300765 width=4) (actual time=64.077..608.825 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6892.16 rows=300765 width=0) (actual time=56.168..56.168 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 3.933 ms Execution time: 30051.615 ms (38 rows) COMMIT; COMMIT