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-09' and l_shipdate > date '1995-03-09' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2687267.99..2687268.02 rows=10 width=20) (actual time=29184.974..29184.977 rows=10 loops=1) Buffers: shared hit=817800 read=549157 written=55 -> Sort (cost=2687267.99..2695139.39 rows=3148558 width=20) (actual time=29184.970..29184.972 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=817800 read=549157 written=55 -> HashAggregate (cost=2587743.21..2619228.79 rows=3148558 width=20) (actual time=29127.930..29165.891 rows=113854 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=817794 read=549157 written=55 -> Hash Join (cost=554435.75..2540514.84 rows=3148558 width=20) (actual time=7378.841..28897.700 rows=300697 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=817794 read=549157 written=55 -> Seq Scan on lineitem (cost=0.00..1831531.51 rows=32816533 width=12) (actual time=0.028..16701.428 rows=32481593 loops=1) Filter: (l_shipdate > '1995-03-09'::date) Rows Removed by Filter: 27502329 Buffers: shared hit=592773 read=482203 -> Hash (cost=536284.32..536284.32 rows=1452114 width=12) (actual time=7366.909..7366.909 rows=1450369 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78705kB Buffers: shared hit=225021 read=66954 written=55 -> Hash Join (cost=49648.90..536284.32 rows=1452114 width=12) (actual time=650.698..6893.746 rows=1450369 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=225021 read=66954 written=55 -> Seq Scan on orders (cost=0.00..444735.19 rows=7301092 width=16) (actual time=0.015..4109.838 rows=7252522 loops=1) Filter: (o_orderdate < '1995-03-09'::date) Rows Removed by Filter: 7747478 Buffers: shared hit=225019 read=30529 -> Hash (cost=45919.71..45919.71 rows=298335 width=4) (actual time=647.834..647.834 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 written=55 -> Bitmap Heap Scan on customer (cost=6912.52..45919.71 rows=298335 width=4) (actual time=61.235..558.387 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=55 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6837.94 rows=298335 width=0) (actual time=53.733..53.733 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 3.594 ms Execution time: 29461.920 ms (38 rows) COMMIT; COMMIT