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=2667162.38..2667162.41 rows=10 width=20) (actual time=40386.968..40386.972 rows=10 loops=1) Buffers: shared hit=829113 read=527317 dirtied=31 written=1812 -> Sort (cost=2667162.38..2675005.12 rows=3137095 width=20) (actual time=40386.963..40386.964 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=829113 read=527317 dirtied=31 written=1812 -> HashAggregate (cost=2567999.94..2599370.89 rows=3137095 width=20) (actual time=40299.655..40365.377 rows=113758 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=829107 read=527317 dirtied=31 written=1812 -> Hash Join (cost=550782.21..2520943.51 rows=3137095 width=20) (actual time=12415.505..40003.082 rows=300310 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=829107 read=527317 dirtied=31 written=1812 -> Seq Scan on lineitem (cost=0.00..1817043.60 rows=32465800 width=12) (actual time=0.056..19327.213 rows=32383480 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27601849 Buffers: shared hit=620705 read=445770 written=3 -> Hash (cost=532646.43..532646.43 rows=1450863 width=12) (actual time=12404.010..12404.010 rows=1455270 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78916kB Buffers: shared hit=208402 read=81547 dirtied=31 written=1809 -> Hash Join (cost=49728.90..532646.43 rows=1450863 width=12) (actual time=1361.336..11720.243 rows=1455270 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=208402 read=81547 dirtied=31 written=1809 -> Seq Scan on orders (cost=0.00..441209.30 rows=7253225 width=16) (actual time=0.024..5637.241 rows=7277150 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7722850 Buffers: shared hit=174351 read=79171 dirtied=31 written=1809 -> Hash (cost=45978.34..45978.34 rows=300045 width=4) (actual time=1358.180..1358.180 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=34051 read=2376 -> Bitmap Heap Scan on customer (cost=6949.78..45978.34 rows=300045 width=4) (actual time=182.040..1191.328 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=34051 read=2376 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.76 rows=300045 width=0) (actual time=164.936..164.936 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 13.528 ms Execution time: 40410.373 ms (38 rows) COMMIT; COMMIT