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-22' and l_shipdate > date '1995-03-22' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2670537.13..2670537.15 rows=10 width=20) (actual time=37393.307..37393.312 rows=10 loops=1) Buffers: shared hit=691991 read=665767 dirtied=2 written=14 -> Sort (cost=2670537.13..2678427.38 rows=3156100 width=20) (actual time=37393.302..37393.303 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=691991 read=665767 dirtied=2 written=14 -> HashAggregate (cost=2570773.94..2602334.94 rows=3156100 width=20) (actual time=37314.336..37372.941 rows=114180 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=691985 read=665767 dirtied=2 written=14 -> Hash Join (cost=552012.24..2523432.44 rows=3156100 width=20) (actual time=10839.217..36999.101 rows=302167 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=691985 read=665767 dirtied=2 written=14 -> Seq Scan on lineitem (cost=0.00..1818872.16 rows=32263210 width=12) (actual time=0.030..19169.090 rows=32190394 loops=1) Filter: (l_shipdate > '1995-03-22'::date) Rows Removed by Filter: 27855209 Buffers: shared hit=484305 read=583241 dirtied=2 written=7 -> Hash (cost=533633.69..533633.69 rows=1470284 width=12) (actual time=10826.894..10826.894 rows=1472223 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79644kB Buffers: shared hit=207680 read=82526 written=7 -> Hash Join (cost=49741.42..533633.69 rows=1470284 width=12) (actual time=816.728..10102.141 rows=1472223 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=207680 read=82526 written=7 -> Seq Scan on orders (cost=0.00..441649.60 rows=7343956 width=16) (actual time=0.027..5233.810 rows=7340860 loops=1) Filter: (o_orderdate < '1995-03-22'::date) Rows Removed by Filter: 7674140 Buffers: shared hit=207456 read=46319 written=7 -> Hash (cost=45987.60..45987.60 rows=300305 width=4) (actual time=812.999..812.999 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=224 read=36207 -> Bitmap Heap Scan on customer (cost=6955.79..45987.60 rows=300305 width=4) (actual time=76.911..707.257 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=224 read=36207 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.72 rows=300305 width=0) (actual time=66.825..66.825 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 3.934 ms Execution time: 37699.364 ms (38 rows) COMMIT; COMMIT