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-24' and l_shipdate > date '1995-03-24' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2699284.15..2699284.18 rows=10 width=20) (actual time=30996.451..30996.455 rows=10 loops=1) Buffers: shared hit=750046 read=622926 written=249 -> Sort (cost=2699284.15..2707219.32 rows=3174065 width=20) (actual time=30996.448..30996.449 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=750046 read=622926 written=249 -> HashAggregate (cost=2598953.10..2630693.75 rows=3174065 width=20) (actual time=30940.939..30977.328 rows=113653 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=750040 read=622926 written=249 -> Hash Join (cost=557335.30..2551342.12 rows=3174065 width=20) (actual time=8402.429..30699.601 rows=300027 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=750040 read=622926 written=249 -> Seq Scan on lineitem (cost=0.00..1840055.36 rows=32589550 width=12) (actual time=0.077..17332.947 rows=32107599 loops=1) Filter: (l_shipdate > '1995-03-24'::date) Rows Removed by Filter: 27877939 Buffers: shared hit=475280 read=604699 -> Hash (cost=538836.41..538836.41 rows=1479911 width=12) (actual time=8390.084..8390.084 rows=1469147 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79512kB Buffers: shared hit=274760 read=18227 written=249 -> Hash Join (cost=49661.09..538836.41 rows=1479911 width=12) (actual time=502.372..7860.565 rows=1469147 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=274760 read=18227 written=249 -> Seq Scan on orders (cost=0.00..446496.39 rows=7434621 width=16) (actual time=0.031..4925.387 rows=7346121 loops=1) Filter: (o_orderdate < '1995-03-24'::date) Rows Removed by Filter: 7653879 Buffers: shared hit=239484 read=17076 written=170 -> Hash (cost=45928.77..45928.77 rows=298585 width=4) (actual time=499.285..499.285 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35276 read=1151 written=79 -> Bitmap Heap Scan on customer (cost=6918.46..45928.77 rows=298585 width=4) (actual time=77.654..415.383 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35276 read=1151 written=79 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.81 rows=298585 width=0) (actual time=68.691..68.691 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=1 read=1151 written=79 Planning time: 3.890 ms Execution time: 31025.230 ms (38 rows) COMMIT; COMMIT