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 = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-20' and l_shipdate > date '1995-03-20' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2699301.44..2699301.46 rows=10 width=20) (actual time=33155.334..33155.337 rows=10 loops=1) Buffers: shared hit=730459 read=641796 dirtied=646 written=689 -> Sort (cost=2699301.44..2707277.36 rows=3190367 width=20) (actual time=33155.331..33155.333 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=730459 read=641796 dirtied=646 written=689 -> HashAggregate (cost=2598455.08..2630358.75 rows=3190367 width=20) (actual time=33092.159..33136.241 rows=113955 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=730453 read=641796 dirtied=646 written=689 -> Hash Join (cost=557530.52..2550599.58 rows=3190367 width=20) (actual time=9174.627..32839.181 rows=300458 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=730453 read=641796 dirtied=646 written=689 -> Seq Scan on lineitem (cost=0.00..1838834.20 rows=32621651 width=12) (actual time=0.029..17223.225 rows=32239322 loops=1) Filter: (l_shipdate > '1995-03-20'::date) Rows Removed by Filter: 27805975 Buffers: shared hit=541073 read=538189 dirtied=646 written=653 -> Hash (cost=538954.92..538954.92 rows=1486048 width=12) (actual time=9161.787..9161.787 rows=1465562 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79358kB Buffers: shared hit=189380 read=103607 written=36 -> Hash Join (cost=49723.50..538954.92 rows=1486048 width=12) (actual time=515.129..8559.562 rows=1465562 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=189380 read=103607 written=36 -> Seq Scan on orders (cost=0.00..446496.39 rows=7433214 width=16) (actual time=0.074..4904.502 rows=7328465 loops=1) Filter: (o_orderdate < '1995-03-20'::date) Rows Removed by Filter: 7686535 Buffers: shared hit=154106 read=102454 written=36 -> Hash (cost=45975.00..45975.00 rows=299880 width=4) (actual time=511.341..511.341 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35274 read=1153 -> Bitmap Heap Scan on customer (cost=6948.50..45975.00 rows=299880 width=4) (actual time=71.432..407.100 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35274 read=1153 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.53 rows=299880 width=0) (actual time=62.333..62.333 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 3.520 ms Execution time: 33175.086 ms (38 rows) COMMIT; COMMIT