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-17' and l_shipdate > date '1995-03-17' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2688017.12..2688017.14 rows=10 width=20) (actual time=33521.593..33521.596 rows=10 loops=1) Buffers: shared hit=948662 read=416984 dirtied=45 written=33 -> Sort (cost=2688017.12..2696003.29 rows=3194469 width=20) (actual time=33521.590..33521.590 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=948662 read=416984 dirtied=45 written=33 -> HashAggregate (cost=2587041.10..2618985.79 rows=3194469 width=20) (actual time=33440.355..33500.095 rows=113932 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=948656 read=416984 dirtied=45 written=33 -> Hash Join (cost=554961.85..2539124.07 rows=3194469 width=20) (actual time=8924.802..33183.609 rows=300490 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=948656 read=416984 dirtied=45 written=33 -> Seq Scan on lineitem (cost=0.00..1829727.39 rows=32664037 width=12) (actual time=0.080..18827.786 rows=32314344 loops=1) Filter: (l_shipdate > '1995-03-17'::date) Rows Removed by Filter: 27730320 Buffers: shared hit=733328 read=340590 dirtied=45 written=2 -> Hash (cost=536478.09..536478.09 rows=1478701 width=12) (actual time=8913.415..8913.415 rows=1461876 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79199kB Buffers: shared hit=215328 read=76394 written=31 -> Hash Join (cost=49796.13..536478.09 rows=1478701 width=12) (actual time=718.211..8360.217 rows=1461876 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=215328 read=76394 written=31 -> Seq Scan on orders (cost=0.00..444294.89 rows=7360016 width=16) (actual time=0.024..5121.560 rows=7309738 loops=1) Filter: (o_orderdate < '1995-03-17'::date) Rows Removed by Filter: 7705262 Buffers: shared hit=201764 read=53531 written=26 -> Hash (cost=46029.07..46029.07 rows=301365 width=4) (actual time=715.127..715.127 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=13564 read=22863 written=5 -> Bitmap Heap Scan on customer (cost=6984.01..46029.07 rows=301365 width=4) (actual time=77.279..621.652 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=13564 read=22863 written=5 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6908.66 rows=301365 width=0) (actual time=67.993..67.993 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 3.602 ms Execution time: 33547.690 ms (38 rows) COMMIT; COMMIT