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#13' 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#22' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 16 and l_quantity <= 16+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#35' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 24 and l_quantity <= 24+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=164606.70..164606.71 rows=1 width=8) (actual time=1018.832..1018.832 rows=1 loops=1) Buffers: shared hit=49674 read=17763 dirtied=41 written=16 -> Nested Loop (cost=25942.76..164598.03 rows=1156 width=8) (actual time=403.521..1017.710 rows=1154 loops=1) Buffers: shared hit=49674 read=17763 dirtied=41 written=16 -> Bitmap Heap Scan on part (cost=25942.20..39823.83 rows=4838 width=30) (actual time=403.364..484.778 rows=4731 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#13'::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#22'::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#35'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4451 Buffers: shared hit=3373 read=4540 written=4 -> BitmapOr (cost=25942.20..25942.20 rows=4842 width=0) (actual time=402.258..402.258 rows=0 loops=1) Buffers: shared hit=1653 read=1809 written=1 -> BitmapAnd (cost=4464.68..4464.68 rows=789 width=0) (actual time=83.867..83.867 rows=0 loops=1) Buffers: shared hit=3 read=606 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.11 rows=7939 width=0) (actual time=6.301..6.301 rows=8078 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#13'::bpchar)) Buffers: shared hit=3 read=58 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4172.90 rows=198847 width=0) (actual time=74.308..74.308 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8638.58..8638.58 rows=1608 width=0) (actual time=134.849..134.849 rows=0 loops=1) Buffers: shared hit=552 read=603 written=1 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.55 rows=8086 width=0) (actual time=5.537..5.537 rows=8054 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#22'::bpchar)) Buffers: shared hit=4 read=57 written=1 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8345.36 rows=397693 width=0) (actual time=125.759..125.759 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 -> BitmapAnd (cost=12838.44..12838.44 rows=2445 width=0) (actual time=182.437..182.437 rows=0 loops=1) Buffers: shared hit=1098 read=600 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..291.47 rows=8176 width=0) (actual time=5.013..5.013 rows=8038 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#35'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..12544.30 rows=597987 width=0) (actual time=174.191..174.191 rows=598661 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=1094 read=544 -> Index Scan using lineitem_l_partkey_l_quantity_l_shipmode_idx on lineitem (cost=0.56..25.78 rows=1 width=16) (actual time=0.098..0.108 rows=0 loops=4731) Index Cond: ((l_partkey = part.p_partkey) AND (l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[]))) Filter: ((l_shipinstruct = 'DELIVER IN PERSON'::bpchar) AND (((l_quantity >= 7::double precision) AND (l_quantity <= 17::double precision)) OR ((l_quantity >= 16::double precision) AND (l_quantity <= 26::double precision)) OR ((l_quantity >= 24::double precision) AND (l_quantity <= 34::double precision))) AND (((part.p_brand = 'Brand#13'::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#22'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 16::double precision) AND (l_quantity <= 26::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#35'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 24::double precision) AND (l_quantity <= 34::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=46301 read=13223 dirtied=41 written=12 Planning time: 7.364 ms Execution time: 1019.389 ms (41 rows) COMMIT; COMMIT