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-29' and l_shipdate > date '1995-03-29' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2683004.02..2683004.05 rows=10 width=20) (actual time=33522.624..33522.629 rows=10 loops=1) Buffers: shared hit=944269 read=420061 written=58 -> Sort (cost=2683004.02..2690922.80 rows=3167513 width=20) (actual time=33522.622..33522.622 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=944269 read=420061 written=58 -> HashAggregate (cost=2582880.08..2614555.21 rows=3167513 width=20) (actual time=33456.080..33501.879 rows=113503 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=944263 read=420061 written=58 -> Hash Join (cost=554721.87..2535367.38 rows=3167513 width=20) (actual time=9308.651..33206.735 rows=299689 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=944263 read=420061 written=58 -> Seq Scan on lineitem (cost=0.00..1827912.74 rows=32282039 width=12) (actual time=0.049..18624.629 rows=32015284 loops=1) Filter: (l_shipdate > '1995-03-29'::date) Rows Removed by Filter: 28030026 Buffers: shared hit=802884 read=269972 -> Hash (cost=536195.65..536195.65 rows=1482097 width=12) (actual time=9291.979..9291.979 rows=1476638 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79834kB Buffers: shared hit=141379 read=150089 written=58 -> Hash Join (cost=49724.64..536195.65 rows=1482097 width=12) (actual time=846.221..8728.613 rows=1476638 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=141379 read=150089 written=58 -> Seq Scan on orders (cost=0.00..443852.85 rows=7412584 width=16) (actual time=0.023..5400.507 rows=7384106 loops=1) Filter: (o_orderdate < '1995-03-29'::date) Rows Removed by Filter: 7630894 Buffers: shared hit=141377 read=113664 written=42 -> Hash (cost=45975.71..45975.71 rows=299915 width=4) (actual time=842.040..842.040 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 written=16 -> Bitmap Heap Scan on customer (cost=6948.77..45975.71 rows=299915 width=4) (actual time=75.212..744.945 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=16 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.79 rows=299915 width=0) (actual time=66.455..66.455 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 4.161 ms Execution time: 33561.200 ms (38 rows) COMMIT; COMMIT