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#12' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 7 and l_quantity <= 7+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#52' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 20 and l_quantity <= 20+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#54' 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=609082.40..609082.41 rows=1 width=8) (actual time=1665.524..1665.524 rows=1 loops=1) Buffers: shared hit=117730 read=66194 dirtied=1037 written=46 -> Nested Loop (cost=12857.08..609073.88 rows=1136 width=8) (actual time=35.927..1664.590 rows=1138 loops=1) Buffers: shared hit=117730 read=66194 dirtied=1037 written=46 -> Bitmap Heap Scan on part (cost=12856.52..26483.68 rows=4726 width=30) (actual time=32.798..140.386 rows=4834 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#12'::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#52'::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#54'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Rows Removed by Index Recheck: 19185 Heap Blocks: exact=18111 Buffers: shared hit=16300 read=1998 -> BitmapOr (cost=12856.52..12856.52 rows=4730 width=0) (actual time=28.991..28.991 rows=0 loops=1) Buffers: shared hit=15 read=172 -> BitmapAnd (cost=2288.27..2288.27 rows=787 width=0) (actual time=8.472..8.472 rows=0 loops=1) Buffers: shared hit=3 read=59 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..272.39 rows=7869 width=0) (actual time=3.578..3.578 rows=7928 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#12'::bpchar)) Buffers: shared hit=3 read=57 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..2013.27 rows=200127 width=0) (actual time=4.189..4.189 rows=405760 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=2 -> BitmapAnd (cost=4298.31..4298.31 rows=1608 width=0) (actual time=8.473..8.473 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..290.23 rows=8051 width=0) (actual time=3.613..3.613 rows=8040 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#52'::bpchar)) Buffers: shared hit=4 read=57 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) (actual time=4.160..4.160 rows=405760 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=6269.43..6269.43 rows=2335 width=0) (actual time=8.256..8.256 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..271.75 rows=7804 width=0) (actual time=3.427..3.427 rows=8051 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::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..5995.07 rows=598307 width=0) (actual time=4.165..4.165 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.26 rows=1 width=16) (actual time=0.280..0.314 rows=0 loops=4834) 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 >= 7::double precision) AND (l_quantity <= 17::double precision)) OR ((l_quantity >= 20::double precision) AND (l_quantity <= 30::double precision)) OR ((l_quantity >= 22::double precision) AND (l_quantity <= 32::double precision))) AND (((part.p_brand = 'Brand#12'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 7::double precision) AND (l_quantity <= 17::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#52'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 20::double precision) AND (l_quantity <= 30::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#54'::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=101430 read=64196 dirtied=1037 written=46 Planning time: 3.862 ms Execution time: 1665.953 ms (42 rows) COMMIT; COMMIT