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-19' and l_shipdate > date '1995-03-19' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2673802.94..2673802.97 rows=10 width=20) (actual time=36918.570..36918.573 rows=10 loops=1) Buffers: shared hit=880831 read=477631 written=823 -> Sort (cost=2673802.94..2681750.88 rows=3179176 width=20) (actual time=36918.567..36918.568 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=880831 read=477631 written=823 -> HashAggregate (cost=2573310.33..2605102.09 rows=3179176 width=20) (actual time=36850.625..36897.857 rows=113906 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=880825 read=477631 written=823 -> Hash Join (cost=552057.06..2525622.69 rows=3179176 width=20) (actual time=10671.055..36606.973 rows=300486 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=880825 read=477631 written=823 -> Seq Scan on lineitem (cost=0.00..1820077.14 rows=32452461 width=12) (actual time=0.042..18737.133 rows=32233419 loops=1) Filter: (l_shipdate > '1995-03-19'::date) Rows Removed by Filter: 27752133 Buffers: shared hit=615550 read=452704 -> Hash (cost=533652.10..533652.10 rows=1472397 width=12) (actual time=10649.954..10649.954 rows=1462844 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79241kB Buffers: shared hit=265275 read=24927 written=823 -> Hash Join (cost=49796.13..533652.10 rows=1472397 width=12) (actual time=633.928..9997.041 rows=1462844 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=265275 read=24927 written=823 -> Seq Scan on orders (cost=0.00..441649.60 rows=7328640 width=16) (actual time=0.041..4980.852 rows=7314750 loops=1) Filter: (o_orderdate < '1995-03-19'::date) Rows Removed by Filter: 7685250 Buffers: shared hit=230385 read=23390 written=759 -> Hash (cost=46029.07..46029.07 rows=301365 width=4) (actual time=627.673..627.673 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=34890 read=1537 written=64 -> Bitmap Heap Scan on customer (cost=6984.01..46029.07 rows=301365 width=4) (actual time=99.742..488.485 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=34890 read=1537 written=64 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6908.66 rows=301365 width=0) (actual time=87.131..87.131 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=53 Planning time: 4.163 ms Execution time: 36947.466 ms (38 rows) COMMIT; COMMIT