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-21' and l_shipdate > date '1995-03-21' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2553167.95..2553167.97 rows=10 width=20) (actual time=37523.154..37523.158 rows=10 loops=1) Buffers: shared hit=653953 read=714388 dirtied=1433 written=2105 -> Sort (cost=2553167.95..2561106.27 rows=3175330 width=20) (actual time=37523.151..37523.153 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=653953 read=714388 dirtied=1433 written=2105 -> HashAggregate (cost=2452796.91..2484550.21 rows=3175330 width=20) (actual time=37454.549..37502.096 rows=114136 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=653947 read=714388 dirtied=1433 written=2105 -> Hash Join (cost=768740.93..2405166.96 rows=3175330 width=20) (actual time=8392.248..37161.235 rows=302122 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=653947 read=714388 dirtied=1433 written=2105 -> Bitmap Heap Scan on lineitem (cost=252263.24..1734944.73 rows=32530999 width=12) (actual time=120.120..22737.116 rows=32213674 loops=1) Recheck Cond: (l_shipdate > '1995-03-21'::date) Rows Removed by Index Recheck: 27830502 Heap Blocks: lossy=1076044 Buffers: shared hit=420073 read=656019 dirtied=925 written=528 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..244130.49 rows=32530999 width=0) (actual time=119.362..119.362 rows=10760960 loops=1) Index Cond: (l_shipdate > '1995-03-21'::date) Buffers: shared hit=13 read=35 written=2 -> Hash (cost=497992.96..497992.96 rows=1478778 width=12) (actual time=8265.787..8265.787 rows=1470814 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79584kB Buffers: shared hit=233874 read=58369 dirtied=508 written=1577 -> Hash Join (cost=107119.16..497992.96 rows=1478778 width=12) (actual time=731.285..7793.074 rows=1470814 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=233874 read=58369 dirtied=508 written=1577 -> Bitmap Heap Scan on orders (cost=57406.70..405734.64 rows=7402155 width=16) (actual time=29.253..4689.862 rows=7334767 loops=1) Recheck Cond: (o_orderdate < '1995-03-21'::date) Rows Removed by Index Recheck: 7680233 Heap Blocks: lossy=255801 Buffers: shared hit=233872 read=21940 dirtied=508 written=203 -> Bitmap Index Scan on orders_o_orderkey_o_orderdate_brin_idx (cost=0.00..55556.17 rows=7402155 width=0) (actual time=29.092..29.092 rows=2558720 loops=1) Index Cond: (o_orderdate < '1995-03-21'::date) Buffers: shared hit=3 read=8 -> Hash (cost=45966.64..45966.64 rows=299665 width=4) (actual time=700.069..700.069 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=1374 -> Bitmap Heap Scan on customer (cost=6942.83..45966.64 rows=299665 width=4) (actual time=79.464..608.754 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=1374 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6867.91 rows=299665 width=0) (actual time=70.576..70.576 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 written=42 Planning time: 3.688 ms Execution time: 37537.965 ms (46 rows) COMMIT; COMMIT