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=2682882.68..2682882.70 rows=10 width=20) (actual time=36866.262..36866.265 rows=10 loops=1) Buffers: shared hit=765500 read=598967 written=2112 -> Sort (cost=2682882.68..2690775.46 rows=3157113 width=20) (actual time=36866.257..36866.259 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=765500 read=598967 written=2112 -> HashAggregate (cost=2583087.47..2614658.60 rows=3157113 width=20) (actual time=36785.070..36844.688 rows=113931 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=765494 read=598967 written=2112 -> Hash Join (cost=554074.18..2535730.77 rows=3157113 width=20) (actual time=9028.030..36492.457 rows=300566 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=765494 read=598967 written=2112 -> Seq Scan on lineitem (cost=0.00..1828148.88 rows=32516424 width=12) (actual time=0.034..19997.296 rows=32232107 loops=1) Filter: (l_shipdate > '1995-03-19'::date) Rows Removed by Filter: 27752802 Buffers: shared hit=530172 read=542821 written=1 -> Hash (cost=535741.89..535741.89 rows=1466583 width=12) (actual time=9011.740..9011.740 rows=1462918 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79244kB Buffers: shared hit=235322 read=56146 written=2111 -> Hash Join (cost=49728.90..535741.89 rows=1466583 width=12) (actual time=845.482..8445.688 rows=1462918 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=235322 read=56146 written=2111 -> Seq Scan on orders (cost=0.00..443852.85 rows=7331816 width=16) (actual time=0.027..5043.087 rows=7314888 loops=1) Filter: (o_orderdate < '1995-03-19'::date) Rows Removed by Filter: 7685112 Buffers: shared hit=235320 read=19721 written=866 -> Hash (cost=45978.34..45978.34 rows=300045 width=4) (actual time=841.320..841.320 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 written=1245 -> Bitmap Heap Scan on customer (cost=6949.78..45978.34 rows=300045 width=4) (actual time=78.434..740.867 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=1245 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.76 rows=300045 width=0) (actual time=68.747..68.747 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=2 Planning time: 3.885 ms Execution time: 36903.095 ms (38 rows) COMMIT; COMMIT