BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select s_name, s_address from supplier, nation where s_suppkey in ( select ps_suppkey from partsupp where ps_partkey in ( select p_partkey from part where p_name like 'white%' ) and ps_availqty > ( select 0.5 * sum(l_quantity) from lineitem where l_partkey = ps_partkey and l_suppkey = ps_suppkey and l_shipdate >= '1997-01-01' and l_shipdate < cast(date '1997-01-01' + interval '1 year' as date) ) ) and s_nationkey = n_nationkey and n_name = 'MOROCCO' order by s_name; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=11672042.14..11672045.05 rows=1163 width=51) (actual time=8136.053..8136.150 rows=1785 loops=1) Sort Key: supplier.s_name Sort Method: quicksort Memory: 256kB Buffers: shared hit=2861014 read=255834 dirtied=778 written=12436 -> Hash Semi Join (cost=11669642.81..11671982.92 rows=1163 width=51) (actual time=8104.904..8133.875 rows=1785 loops=1) Hash Cond: (supplier.s_suppkey = partsupp.ps_suppkey) Buffers: shared hit=2861009 read=255834 dirtied=778 written=12436 -> Nested Loop (cost=43.00..2355.31 rows=4000 width=55) (actual time=0.272..27.745 rows=3990 loops=1) Buffers: shared hit=2157 read=25 -> Seq Scan on nation (cost=0.00..1.31 rows=1 width=4) (actual time=0.010..0.016 rows=1 loops=1) Filter: (n_name = 'MOROCCO'::bpchar) Rows Removed by Filter: 24 Buffers: shared hit=1 -> Bitmap Heap Scan on supplier (cost=43.00..2314.00 rows=4000 width=59) (actual time=0.254..27.119 rows=3990 loops=1) Recheck Cond: (s_nationkey = nation.n_nationkey) Rows Removed by Index Recheck: 96010 Heap Blocks: lossy=2179 Buffers: shared hit=2156 read=25 -> Bitmap Index Scan on supplier_s_nationkey_s_suppkey_brin_idx (cost=0.00..42.00 rows=4000 width=0) (actual time=0.238..0.238 rows=23040 loops=1) Index Cond: (s_nationkey = nation.n_nationkey) Buffers: shared hit=2 -> Hash (cost=11669236.47..11669236.47 rows=29067 width=4) (actual time=8104.419..8104.419 rows=59815 loops=1) Buckets: 65536 (originally 32768) Batches: 1 (originally 1) Memory Usage: 2615kB Buffers: shared hit=2858849 read=255809 dirtied=778 written=12436 -> Nested Loop (cost=754.49..11669236.47 rows=29067 width=4) (actual time=13.338..8069.128 rows=59815 loops=1) Buffers: shared hit=2858849 read=255809 dirtied=778 written=12436 -> Bitmap Heap Scan on part (cost=754.06..34891.52 rows=22022 width=4) (actual time=12.624..227.360 rows=22026 loops=1) Filter: ((p_name)::text ~~ 'white%'::text) Heap Blocks: exact=17003 Buffers: shared hit=7410 read=9743 written=821 -> Bitmap Index Scan on part_p_name_idx (cost=0.00..748.55 rows=20000 width=0) (actual time=9.009..9.009 rows=22026 loops=1) Index Cond: (((p_name)::text >= 'white'::text) AND ((p_name)::text < 'whitf'::text)) Buffers: shared read=150 -> Index Scan using pk_partsupp on partsupp (cost=0.43..528.30 rows=1 width=8) (actual time=0.286..0.355 rows=3 loops=22026) Index Cond: (ps_partkey = part.p_partkey) Filter: ((ps_availqty)::double precision > (SubPlan 1)) Rows Removed by Filter: 1 Buffers: shared hit=2851439 read=246066 dirtied=778 written=11615 SubPlan 1 -> Aggregate (cost=129.34..129.35 rows=1 width=4) (actual time=0.080..0.081 rows=1 loops=88104) Buffers: shared hit=2795399 read=211124 dirtied=778 written=9853 -> Index Scan using lineitem_l_partkey_l_quantity_idx on lineitem (cost=0.56..129.34 rows=1 width=4) (actual time=0.050..0.079 rows=1 loops=88104) Index Cond: (l_partkey = partsupp.ps_partkey) Filter: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1998-01-01'::date) AND (l_suppkey = partsupp.ps_suppkey)) Rows Removed by Filter: 29 Buffers: shared hit=2795399 read=211124 dirtied=778 written=9853 Planning time: 4.568 ms Execution time: 8136.614 ms (48 rows) COMMIT; COMMIT