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-06' and l_shipdate > date '1995-03-06' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2760844.52..2760844.54 rows=10 width=20) (actual time=78317.380..78317.385 rows=10 loops=1) Buffers: shared hit=659472 read=706175 written=7 -> Sort (cost=2760844.52..2768802.03 rows=3183003 width=20) (actual time=78317.375..78317.377 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=659472 read=706175 written=7 -> HashAggregate (cost=2660230.94..2692060.97 rows=3183003 width=20) (actual time=78217.272..78296.313 rows=113965 loops=1) Buffers: shared hit=659466 read=706175 written=7 -> Hash Join (cost=627773.09..2612485.89 rows=3183003 width=20) (actual time=25022.639..77725.460 rows=300771 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=659466 read=706175 written=7 -> Seq Scan on lineitem (cost=0.00..1829719.94 rows=32843423 width=12) (actual time=0.110..30263.988 rows=32589469 loops=1) Filter: (l_shipdate > '1995-03-06'::date) Rows Removed by Filter: 27455195 Buffers: shared hit=405626 read=668292 written=7 -> Hash (cost=609456.26..609456.26 rows=1465346 width=12) (actual time=25020.858..25020.858 rows=1448083 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62223kB Buffers: shared hit=253840 read=37883 -> Hash Join (cost=49723.39..609456.26 rows=1465346 width=12) (actual time=1153.990..24142.754 rows=1448083 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=253840 read=37883 -> Seq Scan on orders (cost=0.00..444294.89 rows=7329784 width=16) (actual time=0.017..6512.005 rows=7240785 loops=1) Filter: (o_orderdate < '1995-03-06'::date) Rows Removed by Filter: 7774215 Buffers: shared hit=253837 read=1458 -> Hash (cost=45974.95..45974.95 rows=299875 width=4) (actual time=1153.769..1153.769 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=3 read=36425 -> Bitmap Heap Scan on customer (cost=6948.51..45974.95 rows=299875 width=4) (actual time=74.715..1000.654 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=3 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.54 rows=299875 width=0) (actual time=66.749..66.749 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 78354.608 ms (35 rows) COMMIT; COMMIT