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-15' and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2685219.68..2685219.70 rows=10 width=20) (actual time=35045.150..35045.152 rows=10 loops=1) Buffers: shared hit=851174 read=514472 written=81 -> Sort (cost=2685219.68..2693113.70 rows=3157608 width=20) (actual time=35045.146..35045.146 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=851174 read=514472 written=81 -> HashAggregate (cost=2585408.83..2616984.91 rows=3157608 width=20) (actual time=34972.403..35023.649 rows=113933 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=851168 read=514472 written=81 -> Hash Join (cost=554369.21..2538044.71 rows=3157608 width=20) (actual time=9595.757..34612.966 rows=300618 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=851168 read=514472 written=81 -> Seq Scan on lineitem (cost=0.00..1829724.88 rows=32633211 width=12) (actual time=0.033..19103.452 rows=32364470 loops=1) Filter: (l_shipdate > '1995-03-15'::date) Rows Removed by Filter: 27680194 Buffers: shared hit=633091 read=440827 -> Hash (cost=536081.47..536081.47 rows=1463019 width=12) (actual time=9581.155..9581.155 rows=1459339 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79090kB Buffers: shared hit=218077 read=73645 written=81 -> Hash Join (cost=49728.90..536081.47 rows=1463019 width=12) (actual time=694.128..8938.871 rows=1459339 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=218077 read=73645 written=81 -> Seq Scan on orders (cost=0.00..444294.89 rows=7313998 width=16) (actual time=0.032..5522.314 rows=7297103 loops=1) Filter: (o_orderdate < '1995-03-15'::date) Rows Removed by Filter: 7717897 Buffers: shared hit=182835 read=72460 written=73 -> Hash (cost=45978.34..45978.34 rows=300045 width=4) (actual time=690.601..690.601 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35242 read=1185 written=8 -> Bitmap Heap Scan on customer (cost=6949.78..45978.34 rows=300045 width=4) (actual time=113.876..561.783 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35242 read=1185 written=8 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.76 rows=300045 width=0) (actual time=101.442..101.442 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=8 Planning time: 5.238 ms Execution time: 35074.578 ms (38 rows) COMMIT; COMMIT