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-29' and l_shipdate > date '1995-03-29' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2698792.36..2698792.38 rows=10 width=20) (actual time=32512.480..32512.484 rows=10 loops=1) Buffers: shared hit=844411 read=527516 written=3653 -> Sort (cost=2698792.36..2706778.44 rows=3194434 width=20) (actual time=32512.478..32512.480 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=844411 read=527516 written=3653 -> HashAggregate (cost=2597817.45..2629761.79 rows=3194434 width=20) (actual time=32440.512..32491.108 rows=112968 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=844405 read=527516 written=3653 -> Hash Join (cost=557314.72..2549900.94 rows=3194434 width=20) (actual time=8648.974..32187.639 rows=297863 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=844405 read=527516 written=3653 -> Seq Scan on lineitem (cost=0.00..1838704.65 rows=32516593 width=12) (actual time=0.030..17995.436 rows=31982465 loops=1) Filter: (l_shipdate > '1995-03-29'::date) Rows Removed by Filter: 28002387 Buffers: shared hit=628740 read=450447 -> Hash (cost=538673.75..538673.75 rows=1491278 width=12) (actual time=8635.776..8635.776 rows=1471582 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79617kB Buffers: shared hit=215665 read=77069 written=3653 -> Hash Join (cost=49712.62..538673.75 rows=1491278 width=12) (actual time=831.050..8075.210 rows=1471582 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=215665 read=77069 written=3653 -> Seq Scan on orders (cost=0.00..446056.09 rows=7464603 width=16) (actual time=0.028..4660.138 rows=7376933 loops=1) Filter: (o_orderdate < '1995-03-29'::date) Rows Removed by Filter: 7623067 Buffers: shared hit=215663 read=40644 written=104 -> Hash (cost=45966.74..45966.74 rows=299670 width=4) (actual time=827.747..827.747 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 written=3549 -> Bitmap Heap Scan on customer (cost=6942.87..45966.74 rows=299670 width=4) (actual time=73.006..727.828 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=3549 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6867.95 rows=299670 width=0) (actual time=63.918..63.918 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 written=83 Planning time: 4.071 ms Execution time: 32543.680 ms (38 rows) COMMIT; COMMIT