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-18' and l_shipdate > date '1995-03-18' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2745696.40..2745696.42 rows=10 width=20) (actual time=84622.503..84622.507 rows=10 loops=1) Buffers: shared hit=856068 read=503002 -> Sort (cost=2745696.40..2753568.99 rows=3149037 width=20) (actual time=84622.499..84622.500 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=856068 read=503002 -> HashAggregate (cost=2646156.47..2677646.84 rows=3149037 width=20) (actual time=84501.166..84591.675 rows=113920 loops=1) Buffers: shared hit=856062 read=503002 -> Hash Join (cost=625440.57..2598920.92 rows=3149037 width=20) (actual time=27059.058..83892.995 rows=300511 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=856062 read=503002 -> Seq Scan on lineitem (cost=0.00..1820677.18 rows=32350081 width=12) (actual time=0.048..31325.172 rows=32290128 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27755251 Buffers: shared hit=574556 read=494052 -> Hash (cost=607134.16..607134.16 rows=1464513 width=12) (actual time=27057.133..27057.133 rows=1463012 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62864kB Buffers: shared hit=281506 read=8950 -> Hash Join (cost=49728.95..607134.16 rows=1464513 width=12) (actual time=716.334..26170.853 rows=1463012 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=281506 read=8950 -> Seq Scan on orders (cost=0.00..442089.90 rows=7321467 width=16) (actual time=0.012..6736.955 rows=7315809 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7699191 Buffers: shared hit=252760 read=1268 -> Hash (cost=45978.39..45978.39 rows=300045 width=4) (actual time=716.112..716.112 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=28746 read=7682 -> Bitmap Heap Scan on customer (cost=6949.83..45978.39 rows=300045 width=4) (actual time=72.040..580.338 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=28746 read=7682 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.82 rows=300045 width=0) (actual time=62.735..62.735 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 84677.564 ms (35 rows) COMMIT; COMMIT