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-16' and l_shipdate > date '1995-03-16' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2696674.09..2696674.11 rows=10 width=20) (actual time=35493.745..35493.749 rows=10 loops=1) Buffers: shared hit=794672 read=576256 written=167 -> Sort (cost=2696674.09..2704636.72 rows=3185054 width=20) (actual time=35493.741..35493.744 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=794672 read=576256 written=167 -> HashAggregate (cost=2595995.67..2627846.21 rows=3185054 width=20) (actual time=35420.071..35473.262 rows=113954 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=794666 read=576256 written=167 -> Hash Join (cost=556822.17..2548219.86 rows=3185054 width=20) (actual time=9192.826..35139.235 rows=300486 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=794666 read=576256 written=167 -> Seq Scan on lineitem (cost=0.00..1837004.34 rows=32678084 width=12) (actual time=0.026..18404.041 rows=32340072 loops=1) Filter: (l_shipdate > '1995-03-16'::date) Rows Removed by Filter: 27704922 Buffers: shared hit=560345 read=517843 -> Hash (cost=538327.78..538327.78 rows=1479551 width=12) (actual time=9175.387..9175.387 rows=1460453 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79138kB Buffers: shared hit=234321 read=58413 written=167 -> Hash Join (cost=49723.50..538327.78 rows=1479551 width=12) (actual time=529.404..8580.391 rows=1460453 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=234321 read=58413 written=167 -> Seq Scan on orders (cost=0.00..446056.09 rows=7400717 width=16) (actual time=0.024..4797.888 rows=7303246 loops=1) Filter: (o_orderdate < '1995-03-16'::date) Rows Removed by Filter: 7711754 Buffers: shared hit=207173 read=49134 written=3 -> Hash (cost=45975.00..45975.00 rows=299880 width=4) (actual time=526.107..526.107 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=27148 read=9279 written=164 -> Bitmap Heap Scan on customer (cost=6948.50..45975.00 rows=299880 width=4) (actual time=65.642..431.886 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=27148 read=9279 written=164 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.53 rows=299880 width=0) (actual time=57.295..57.295 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=6 Planning time: 3.893 ms Execution time: 35515.216 ms (38 rows) COMMIT; COMMIT