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-06' and l_shipdate > date '1995-03-06' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2667616.34..2667616.37 rows=10 width=20) (actual time=29980.248..29980.250 rows=10 loops=1) Buffers: shared hit=802183 read=554247 -> Sort (cost=2667616.34..2675462.33 rows=3138395 width=20) (actual time=29980.244..29980.245 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=802183 read=554247 -> HashAggregate (cost=2568412.80..2599796.75 rows=3138395 width=20) (actual time=29924.986..29961.048 rows=113082 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=802177 read=554247 -> Hash Join (cost=550537.48..2521336.88 rows=3138395 width=20) (actual time=7684.800..29718.347 rows=298527 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=802177 read=554247 -> Seq Scan on lineitem (cost=0.00..1817047.41 rows=32631478 width=12) (actual time=0.026..17472.484 rows=32591374 loops=1) Filter: (l_shipdate > '1995-03-06'::date) Rows Removed by Filter: 27454295 Buffers: shared hit=513380 read=553095 -> Hash (cost=532486.29..532486.29 rows=1444095 width=12) (actual time=7677.010..7677.010 rows=1444328 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78445kB Buffers: shared hit=288797 read=1152 -> Hash Join (cost=49696.83..532486.29 rows=1444095 width=12) (actual time=434.954..7256.974 rows=1444328 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288797 read=1152 -> Seq Scan on orders (cost=0.00..441209.30 rows=7237122 width=16) (actual time=0.018..4884.109 rows=7240482 loops=1) Filter: (o_orderdate < '1995-03-06'::date) Rows Removed by Filter: 7774518 Buffers: shared hit=253522 -> Hash (cost=45955.46..45955.46 rows=299310 width=4) (actual time=432.533..432.533 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6936.08..45955.46 rows=299310 width=4) (actual time=67.026..358.390 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6861.25 rows=299310 width=0) (actual time=58.637..58.637 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 5.299 ms Execution time: 30003.376 ms (38 rows) COMMIT; COMMIT