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-15' and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2672481.73..2672481.76 rows=10 width=20) (actual time=31897.239..31897.243 rows=10 loops=1) Buffers: shared hit=880474 read=477280 -> Sort (cost=2672481.73..2680421.71 rows=3175989 width=20) (actual time=31897.237..31897.238 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=880474 read=477280 -> HashAggregate (cost=2572089.86..2603849.75 rows=3175989 width=20) (actual time=31828.850..31876.561 rows=113897 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=880468 read=477280 -> Hash Join (cost=551871.81..2524450.03 rows=3175989 width=20) (actual time=8066.171..31575.460 rows=300543 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=880468 read=477280 -> Seq Scan on lineitem (cost=0.00..1818870.86 rows=32519323 width=12) (actual time=0.025..18041.129 rows=32365888 loops=1) Filter: (l_shipdate > '1995-03-15'::date) Rows Removed by Filter: 27679715 Buffers: shared hit=616500 read=451046 -> Hash (cost=533523.10..533523.10 rows=1467897 width=12) (actual time=8053.367..8053.367 rows=1459209 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79085kB Buffers: shared hit=263968 read=26234 -> Hash Join (cost=49796.13..533523.10 rows=1467897 width=12) (actual time=469.816..7523.147 rows=1459209 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=263968 read=26234 -> Seq Scan on orders (cost=0.00..441649.60 rows=7306240 width=16) (actual time=0.027..4575.213 rows=7296925 loops=1) Filter: (o_orderdate < '1995-03-15'::date) Rows Removed by Filter: 7718075 Buffers: shared hit=228694 read=25081 -> Hash (cost=46029.07..46029.07 rows=301365 width=4) (actual time=466.822..466.822 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35274 read=1153 -> Bitmap Heap Scan on customer (cost=6984.01..46029.07 rows=301365 width=4) (actual time=73.365..378.436 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..6908.66 rows=301365 width=0) (actual time=63.859..63.859 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 3.590 ms Execution time: 31929.209 ms (38 rows) COMMIT; COMMIT