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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-15' and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2741240.27..2741240.30 rows=10 width=20) (actual time=49307.343..49307.348 rows=10 loops=1) Buffers: shared hit=839000 read=517435 -> Sort (cost=2741240.27..2749132.15 rows=3156750 width=20) (actual time=49307.336..49307.339 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=839000 read=517435 -> HashAggregate (cost=2641456.54..2673024.04 rows=3156750 width=20) (actual time=49233.108..49288.832 rows=114128 loops=1) Buffers: shared hit=838994 read=517435 -> Hash Join (cost=624181.68..2594105.29 rows=3156750 width=20) (actual time=18306.230..48956.530 rows=302423 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=838994 read=517435 -> Seq Scan on lineitem (cost=0.00..1817050.21 rows=32348238 width=12) (actual time=0.037..17458.207 rows=32366276 loops=1) Filter: (l_shipdate > '1995-03-15'::date) Rows Removed by Filter: 27679393 Buffers: shared hit=550195 read=516280 -> Hash (cost=605865.95..605865.95 rows=1465259 width=12) (actual time=18303.868..18303.868 rows=1463368 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62880kB Buffers: shared hit=288799 read=1155 -> Hash Join (cost=49808.54..605865.95 rows=1465259 width=12) (actual time=430.046..17735.026 rows=1463368 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288799 read=1155 -> Seq Scan on orders (cost=0.00..441209.30 rows=7286947 width=16) (actual time=0.015..4728.087 rows=7296828 loops=1) Filter: (o_orderdate < '1995-03-15'::date) Rows Removed by Filter: 7718172 Buffers: shared hit=253522 -> Hash (cost=46038.29..46038.29 rows=301620 width=4) (actual time=429.815..429.815 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=35277 read=1155 -> Bitmap Heap Scan on customer (cost=6990.04..46038.29 rows=301620 width=4) (actual time=70.744..361.393 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=35277 read=1155 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6914.63 rows=301620 width=0) (actual time=62.320..62.320 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 49339.143 ms (35 rows) COMMIT; COMMIT