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-20' and l_shipdate > date '1995-03-20' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2759197.00..2759197.03 rows=10 width=20) (actual time=82619.798..82619.804 rows=10 loops=1) Buffers: shared hit=751326 read=614321 -> Sort (cost=2759197.00..2767110.49 rows=3165397 width=20) (actual time=82619.795..82619.799 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=751326 read=614321 -> HashAggregate (cost=2659139.94..2690793.91 rows=3165397 width=20) (actual time=82491.965..82586.722 rows=113822 loops=1) Buffers: shared hit=751320 read=614321 -> Hash Join (cost=628586.21..2611658.98 rows=3165397 width=20) (actual time=28282.649..81996.829 rows=300123 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=751320 read=614321 -> Seq Scan on lineitem (cost=0.00..1829724.26 rows=32451879 width=12) (actual time=0.041..31221.223 rows=32206498 loops=1) Filter: (l_shipdate > '1995-03-20'::date) Rows Removed by Filter: 27778021 Buffers: shared hit=460751 read=613167 -> Hash (cost=610150.92..610150.92 rows=1474823 width=12) (actual time=28280.706..28280.706 rows=1464139 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62913kB Buffers: shared hit=290569 read=1154 -> Hash Join (cost=49728.95..610150.92 rows=1474823 width=12) (actual time=961.035..27381.053 rows=1464139 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=290569 read=1154 -> Seq Scan on orders (cost=0.00..444294.89 rows=7373007 width=16) (actual time=0.016..7030.247 rows=7321210 loops=1) Filter: (o_orderdate < '1995-03-20'::date) Rows Removed by Filter: 7678790 Buffers: shared hit=255292 read=3 -> Hash (cost=45978.39..45978.39 rows=300045 width=4) (actual time=960.803..960.803 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=35277 read=1151 -> Bitmap Heap Scan on customer (cost=6949.83..45978.39 rows=300045 width=4) (actual time=73.924..453.330 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=35277 read=1151 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.82 rows=300045 width=0) (actual time=64.526..64.526 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=3 read=1150 Total runtime: 82663.165 ms (35 rows) COMMIT; COMMIT