BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#55' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 1 and l_quantity <= 1+10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#54' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 17 and l_quantity <= 17+10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#11' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 22 and l_quantity <= 22+10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=604381.80..604381.81 rows=1 width=8) (actual time=1822.178..1822.178 rows=1 loops=1) Buffers: shared hit=109792 read=75192 dirtied=549 written=44 -> Nested Loop (cost=12856.02..604373.40 rows=1120 width=8) (actual time=33.757..1821.259 rows=1132 loops=1) Buffers: shared hit=109792 read=75192 dirtied=549 written=44 -> Bitmap Heap Scan on part (cost=12855.46..26393.17 rows=4688 width=30) (actual time=33.433..305.019 rows=4859 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#55'::bpchar) AND (p_size <= 5) AND (p_size >= 1)) OR ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#54'::bpchar) AND (p_size <= 10) AND (p_size >= 1)) OR ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#11'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Rows Removed by Index Recheck: 19353 Heap Blocks: exact=18328 Buffers: shared hit=16 read=18500 written=9 -> BitmapOr (cost=12855.46..12855.46 rows=4691 width=0) (actual time=29.320..29.320 rows=0 loops=1) Buffers: shared hit=15 read=173 -> BitmapAnd (cost=2305.49..2305.49 rows=800 width=0) (actual time=8.579..8.579 rows=0 loops=1) Buffers: shared hit=3 read=60 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.63 rows=7993 width=0) (actual time=3.654..3.654 rows=8101 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#55'::bpchar)) Buffers: shared hit=3 read=58 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..2013.27 rows=200127 width=0) (actual time=4.201..4.201 rows=405760 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=2 -> BitmapAnd (cost=4280.61..4280.61 rows=1574 width=0) (actual time=8.643..8.643 rows=0 loops=1) Buffers: shared hit=6 read=56 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..272.55 rows=7884 width=0) (actual time=3.724..3.724 rows=8100 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#54'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) (actual time=4.179..4.179 rows=405760 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=6268.85..6268.85 rows=2317 width=0) (actual time=8.333..8.333 rows=0 loops=1) Buffers: shared hit=6 read=57 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..271.19 rows=7747 width=0) (actual time=3.456..3.456 rows=8011 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#11'::bpchar)) Buffers: shared hit=4 read=57 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..5995.07 rows=598307 width=0) (actual time=4.168..4.168 rows=405760 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=2 -> Index Scan using lineitem_l_partkey_l_quantity_idx on lineitem (cost=0.56..123.28 rows=1 width=16) (actual time=0.277..0.310 rows=0 loops=4859) Index Cond: (l_partkey = part.p_partkey) Filter: ((l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[])) AND (l_shipinstruct = 'DELIVER IN PERSON'::bpchar) AND (((l_quantity >= 1::double precision) AND (l_quantity <= 11::double precision)) OR ((l_quantity >= 17::double precision) AND (l_quantity <= 27::double precision)) OR ((l_quantity >= 22::double precision) AND (l_quantity <= 32::double precision))) AND (((part.p_brand = 'Brand#55'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 1::double precision) AND (l_quantity <= 11::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#54'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 17::double precision) AND (l_quantity <= 27::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#11'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 22::double precision) AND (l_quantity <= 32::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 30 Buffers: shared hit=109776 read=56692 dirtied=549 written=35 Planning time: 4.448 ms Execution time: 1822.537 ms (42 rows) COMMIT; COMMIT