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=2674320.50..2674320.53 rows=10 width=20) (actual time=36678.192..36678.196 rows=10 loops=1) Buffers: shared hit=781618 read=578762 dirtied=580 written=585 -> Sort (cost=2674320.50..2682179.89 rows=3143755 width=20) (actual time=36678.189..36678.190 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=781618 read=578762 dirtied=580 written=585 -> HashAggregate (cost=2574947.54..2606385.09 rows=3143755 width=20) (actual time=36588.575..36656.672 rows=113717 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=781612 read=578762 dirtied=580 written=585 -> Hash Join (cost=552825.67..2527791.21 rows=3143755 width=20) (actual time=8969.846..36250.881 rows=300182 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=781612 read=578762 dirtied=580 written=585 -> Seq Scan on lineitem (cost=0.00..1822484.20 rows=32278344 width=12) (actual time=0.037..19476.409 rows=32140675 loops=1) Filter: (l_shipdate > '1995-03-24'::date) Rows Removed by Filter: 27904628 Buffers: shared hit=595269 read=474397 dirtied=580 written=576 -> Hash (cost=534491.11..534491.11 rows=1466765 width=12) (actual time=8956.758..8956.758 rows=1470512 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79571kB Buffers: shared hit=186343 read=104365 written=9 -> Hash Join (cost=49661.09..534491.11 rows=1466765 width=12) (actual time=878.939..8413.481 rows=1470512 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=186343 read=104365 written=9 -> Seq Scan on orders (cost=0.00..442530.20 rows=7368580 width=16) (actual time=0.025..5014.044 rows=7353251 loops=1) Filter: (o_orderdate < '1995-03-24'::date) Rows Removed by Filter: 7661749 Buffers: shared hit=184084 read=70197 written=9 -> Hash (cost=45928.77..45928.77 rows=298585 width=4) (actual time=875.251..875.251 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2259 read=34168 -> Bitmap Heap Scan on customer (cost=6918.46..45928.77 rows=298585 width=4) (actual time=79.372..766.330 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2259 read=34168 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.81 rows=298585 width=0) (actual time=70.203..70.203 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 6.241 ms Execution time: 36706.494 ms (38 rows) COMMIT; COMMIT