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-28' and l_shipdate > date '1995-03-28' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2745452.63..2745452.65 rows=10 width=20) (actual time=66226.269..66226.273 rows=10 loops=1) Buffers: shared hit=1085072 read=274002 dirtied=252 written=47 -> Sort (cost=2745452.63..2753312.44 rows=3143923 width=20) (actual time=66226.264..66226.265 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=1085072 read=274002 dirtied=252 written=47 -> HashAggregate (cost=2646074.35..2677513.58 rows=3143923 width=20) (actual time=66134.977..66205.276 rows=113992 loops=1) Buffers: shared hit=1085066 read=274002 dirtied=252 written=47 -> Hash Join (cost=626394.17..2598915.51 rows=3143923 width=20) (actual time=25255.370..65802.437 rows=301671 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1085066 read=274002 dirtied=252 written=47 -> Seq Scan on lineitem (cost=0.00..1820682.79 rows=32106485 width=12) (actual time=0.061..21230.030 rows=32040195 loops=1) Filter: (l_shipdate > '1995-03-28'::date) Rows Removed by Filter: 28005184 Buffers: shared hit=889903 read=178705 -> Hash (cost=607978.82..607978.82 rows=1473228 width=12) (actual time=25253.036..25253.036 rows=1479393 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63568kB Buffers: shared hit=195163 read=95297 dirtied=252 written=47 -> Hash Join (cost=49703.11..607978.82 rows=1473228 width=12) (actual time=672.620..24470.433 rows=1479393 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=195163 read=95297 dirtied=252 written=47 -> Seq Scan on orders (cost=0.00..442089.90 rows=7378439 width=16) (actual time=0.017..6020.002 rows=7377907 loops=1) Filter: (o_orderdate < '1995-03-28'::date) Rows Removed by Filter: 7637093 Buffers: shared hit=161140 read=92888 dirtied=252 written=47 -> Hash (cost=45959.36..45959.36 rows=299500 width=4) (actual time=672.377..672.377 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=34023 read=2409 -> Bitmap Heap Scan on customer (cost=6937.61..45959.36 rows=299500 width=4) (actual time=73.953..534.647 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=34023 read=2409 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6862.73 rows=299500 width=0) (actual time=64.126..64.126 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 66262.225 ms (35 rows) COMMIT; COMMIT