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-17' and l_shipdate > date '1995-03-17' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2669527.34..2669527.37 rows=10 width=20) (actual time=42982.849..42982.853 rows=10 loops=1) Buffers: shared hit=691240 read=666514 -> Sort (cost=2669527.34..2677376.13 rows=3139513 width=20) (actual time=42982.844..42982.845 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=691240 read=666514 -> HashAggregate (cost=2570288.47..2601683.60 rows=3139513 width=20) (actual time=42880.592..42960.959 rows=113899 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=691234 read=666514 -> Hash Join (cost=551467.65..2523195.77 rows=3139513 width=20) (actual time=12261.384..42342.653 rows=300424 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=691234 read=666514 -> Seq Scan on lineitem (cost=0.00..1818868.36 rows=32390569 width=12) (actual time=0.033..21304.905 rows=32315744 loops=1) Filter: (l_shipdate > '1995-03-17'::date) Rows Removed by Filter: 27729859 Buffers: shared hit=402471 read=665075 -> Hash (cost=533257.57..533257.57 rows=1456806 width=12) (actual time=12247.949..12247.949 rows=1461747 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79194kB Buffers: shared hit=288763 read=1439 -> Hash Join (cost=49728.90..533257.57 rows=1456806 width=12) (actual time=678.529..11489.728 rows=1461747 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288763 read=1439 -> Seq Scan on orders (cost=0.00..441649.60 rows=7282936 width=16) (actual time=0.037..6736.118 rows=7309579 loops=1) Filter: (o_orderdate < '1995-03-17'::date) Rows Removed by Filter: 7705421 Buffers: shared hit=253488 read=287 -> Hash (cost=45978.34..45978.34 rows=300045 width=4) (actual time=675.303..675.303 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6949.78..45978.34 rows=300045 width=4) (actual time=110.777..550.307 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.76 rows=300045 width=0) (actual time=98.816..98.816 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 5.407 ms Execution time: 43013.093 ms (38 rows) COMMIT; COMMIT