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-23' and l_shipdate > date '1995-03-23' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2534328.93..2534328.95 rows=10 width=20) (actual time=36101.546..36101.550 rows=10 loops=1) Buffers: shared hit=1038722 read=320407 dirtied=210 written=504 -> Sort (cost=2534328.93..2542206.10 rows=3150867 width=20) (actual time=36101.543..36101.545 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=1038722 read=320407 dirtied=210 written=504 -> HashAggregate (cost=2434731.16..2466239.83 rows=3150867 width=20) (actual time=36036.011..36080.095 rows=114110 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1038716 read=320407 dirtied=210 written=504 -> Hash Join (cost=763508.90..2387468.15 rows=3150867 width=20) (actual time=12450.348..35780.713 rows=301967 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1038716 read=320407 dirtied=210 written=504 -> Bitmap Heap Scan on lineitem (cost=249982.04..1721545.18 rows=32236651 width=12) (actual time=118.310..17897.215 rows=32165382 loops=1) Recheck Cond: (l_shipdate > '1995-03-23'::date) Rows Removed by Index Recheck: 27879997 Heap Blocks: lossy=1068605 Buffers: shared hit=1034731 read=33922 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..241922.88 rows=32236651 width=0) (actual time=117.578..117.578 rows=10686720 loops=1) Index Cond: (l_shipdate > '1995-03-23'::date) Buffers: shared hit=48 -> Hash (cost=495145.36..495145.36 rows=1470520 width=12) (actual time=12323.110..12323.110 rows=1473283 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79690kB Buffers: shared hit=3985 read=286485 dirtied=210 written=504 -> Hash Join (cost=106798.82..495145.36 rows=1470520 width=12) (actual time=803.603..11736.894 rows=1473283 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=3985 read=286485 dirtied=210 written=504 -> Bitmap Heap Scan on orders (cost=57086.36..403124.63 rows=7360821 width=16) (actual time=33.285..8109.150 rows=7347063 loops=1) Recheck Cond: (o_orderdate < '1995-03-23'::date) Rows Removed by Index Recheck: 7667937 Heap Blocks: lossy=254028 Buffers: shared hit=3983 read=250056 dirtied=210 written=480 -> Bitmap Index Scan on orders_o_orderkey_o_orderdate_brin_idx (cost=0.00..55246.16 rows=7360821 width=0) (actual time=33.125..33.125 rows=2540800 loops=1) Index Cond: (o_orderdate < '1995-03-23'::date) Buffers: shared hit=3 read=8 -> Hash (cost=45966.64..45966.64 rows=299665 width=4) (actual time=768.025..768.025 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=24 -> Bitmap Heap Scan on customer (cost=6942.83..45966.64 rows=299665 width=4) (actual time=77.795..667.457 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=24 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6867.91 rows=299665 width=0) (actual time=68.983..68.983 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 3.357 ms Execution time: 36115.829 ms (46 rows) COMMIT; COMMIT