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-13' and l_shipdate > date '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2693338.36..2693338.39 rows=10 width=20) (actual time=38090.091..38090.095 rows=10 loops=1) Buffers: shared hit=881433 read=486847 dirtied=226 written=194 -> Sort (cost=2693338.36..2701337.25 rows=3199556 width=20) (actual time=38090.087..38090.088 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=881433 read=486847 dirtied=226 written=194 -> HashAggregate (cost=2592201.55..2624197.11 rows=3199556 width=20) (actual time=38001.889..38069.587 rows=113889 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=881427 read=486847 dirtied=226 written=194 -> Hash Join (cost=555755.60..2544208.21 rows=3199556 width=20) (actual time=9921.859..37707.332 rows=300675 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=881427 read=486847 dirtied=226 written=194 -> Seq Scan on lineitem (cost=0.00..1833353.05 rows=32827733 width=12) (actual time=0.038..19469.201 rows=32414041 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27630135 Buffers: shared hit=714695 read=361351 -> Hash (cost=537298.21..537298.21 rows=1476591 width=12) (actual time=9906.633..9906.633 rows=1456790 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78981kB Buffers: shared hit=166732 read=125496 dirtied=226 written=194 -> Hash Join (cost=49796.13..537298.21 rows=1476591 width=12) (actual time=677.952..9299.126 rows=1456790 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=166732 read=125496 dirtied=226 written=194 -> Seq Scan on orders (cost=0.00..445175.49 rows=7349516 width=16) (actual time=0.031..5526.362 rows=7284649 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7730351 Buffers: shared hit=148915 read=106886 dirtied=226 written=158 -> Hash (cost=46029.07..46029.07 rows=301365 width=4) (actual time=674.445..674.445 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=17817 read=18610 written=36 -> Bitmap Heap Scan on customer (cost=6984.01..46029.07 rows=301365 width=4) (actual time=79.073..572.775 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=17817 read=18610 written=36 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6908.66 rows=301365 width=0) (actual time=69.973..69.973 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=3 Planning time: 3.843 ms Execution time: 38114.733 ms (38 rows) COMMIT; COMMIT