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-21' and l_shipdate > date '1995-03-21' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2669629.04..2669629.06 rows=10 width=20) (actual time=30293.285..30293.290 rows=10 loops=1) Buffers: shared hit=804554 read=551876 -> Sort (cost=2669629.04..2677562.78 rows=3173495 width=20) (actual time=30293.280..30293.282 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=804554 read=551876 -> HashAggregate (cost=2569316.00..2601050.95 rows=3173495 width=20) (actual time=30237.354..30274.289 rows=113845 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=804548 read=551876 -> Hash Join (cost=551659.16..2521713.58 rows=3173495 width=20) (actual time=7717.590..30019.578 rows=300246 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=804548 read=551876 -> Seq Scan on lineitem (cost=0.00..1817046.11 rows=32339562 width=12) (actual time=0.034..17827.652 rows=32215897 loops=1) Filter: (l_shipdate > '1995-03-21'::date) Rows Removed by Filter: 27829772 Buffers: shared hit=515751 read=550724 -> Hash (cost=533241.32..533241.32 rows=1473427 width=12) (actual time=7709.418..7709.418 rows=1466679 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79406kB Buffers: shared hit=288797 read=1152 -> Hash Join (cost=49796.13..533241.32 rows=1473427 width=12) (actual time=469.707..7269.514 rows=1466679 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=7333765 width=16) (actual time=0.018..4844.701 rows=7334454 loops=1) Filter: (o_orderdate < '1995-03-21'::date) Rows Removed by Filter: 7680546 Buffers: shared hit=253522 -> Hash (cost=46029.07..46029.07 rows=301365 width=4) (actual time=467.226..467.226 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6984.01..46029.07 rows=301365 width=4) (actual time=68.201..391.730 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6908.66 rows=301365 width=0) (actual time=59.777..59.777 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 4.510 ms Execution time: 30313.175 ms (38 rows) COMMIT; COMMIT