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-28' and l_shipdate > date '1995-03-28' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2757838.38..2757838.41 rows=10 width=20) (actual time=86193.900..86193.904 rows=10 loops=1) Buffers: shared hit=999304 read=365027 written=179 -> Sort (cost=2757838.38..2765786.28 rows=3179159 width=20) (actual time=86193.895..86193.896 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=999304 read=365027 written=179 -> HashAggregate (cost=2657346.31..2689137.90 rows=3179159 width=20) (actual time=86097.831..86171.638 rows=113639 loops=1) Buffers: shared hit=999298 read=365027 written=179 -> Hash Join (cost=629190.87..2609658.92 rows=3179159 width=20) (actual time=25855.129..85566.330 rows=300004 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=999298 read=365027 written=179 -> Seq Scan on lineitem (cost=0.00..1827915.35 rows=32202964 width=12) (actual time=0.056..34320.180 rows=32040231 loops=1) Filter: (l_shipdate > '1995-03-28'::date) Rows Removed by Filter: 28005079 Buffers: shared hit=709182 read=363674 -> Hash (cost=610550.88..610550.88 rows=1491199 width=12) (actual time=25851.774..25851.774 rows=1475460 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63399kB Buffers: shared hit=290116 read=1353 written=179 -> Hash Join (cost=49803.23..610550.88 rows=1491199 width=12) (actual time=694.553..25069.221 rows=1475460 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=290116 read=1353 written=179 -> Seq Scan on orders (cost=0.00..443852.85 rows=7416932 width=16) (actual time=0.028..6356.939 rows=7377882 loops=1) Filter: (o_orderdate < '1995-03-28'::date) Rows Removed by Filter: 7637118 Buffers: shared hit=254890 read=151 written=8 -> Hash (cost=46033.48..46033.48 rows=301580 width=4) (actual time=694.144..694.144 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=35226 read=1202 written=171 -> Bitmap Heap Scan on customer (cost=6985.73..46033.48 rows=301580 width=4) (actual time=134.496..566.712 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=35226 read=1202 written=171 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.33 rows=301580 width=0) (actual time=121.239..121.239 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 written=166 Total runtime: 86248.810 ms (35 rows) COMMIT; COMMIT