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-11' and l_shipdate > date '1995-03-11' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2682108.45..2682108.47 rows=10 width=20) (actual time=35370.398..35370.403 rows=10 loops=1) Buffers: shared hit=680191 read=684139 dirtied=591 written=591 -> Sort (cost=2682108.45..2689968.40 rows=3143981 width=20) (actual time=35370.394..35370.397 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=680191 read=684139 dirtied=591 written=591 -> HashAggregate (cost=2582728.34..2614168.15 rows=3143981 width=20) (actual time=35276.408..35350.172 rows=113901 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=680185 read=684139 dirtied=591 written=591 -> Hash Join (cost=553537.43..2535568.62 rows=3143981 width=20) (actual time=10391.649..34976.629 rows=300742 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=680185 read=684139 dirtied=591 written=591 -> Seq Scan on lineitem (cost=0.00..1827919.48 rows=32712508 width=12) (actual time=0.050..17602.977 rows=32465755 loops=1) Filter: (l_shipdate > '1995-03-11'::date) Rows Removed by Filter: 27579555 Buffers: shared hit=529126 read=543730 dirtied=591 written=591 -> Hash (cost=535390.83..535390.83 rows=1451728 width=12) (actual time=10379.707..10379.707 rows=1454225 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78871kB Buffers: shared hit=151059 read=140409 -> Hash Join (cost=49648.90..535390.83 rows=1451728 width=12) (actual time=708.498..9638.228 rows=1454225 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=151059 read=140409 -> Seq Scan on orders (cost=0.00..443852.85 rows=7299148 width=16) (actual time=0.024..4768.889 rows=7271831 loops=1) Filter: (o_orderdate < '1995-03-11'::date) Rows Removed by Filter: 7743169 Buffers: shared hit=151057 read=103984 -> Hash (cost=45919.71..45919.71 rows=298335 width=4) (actual time=705.541..705.541 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 -> Bitmap Heap Scan on customer (cost=6912.52..45919.71 rows=298335 width=4) (actual time=67.929..612.951 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6837.94 rows=298335 width=0) (actual time=59.609..59.609 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 4.028 ms Execution time: 35404.807 ms (38 rows) COMMIT; COMMIT