Justin thank you very much for your answer, as you can also see the number of
rows differs a lot
I attach the complete explain, do not attach it because it is large
"HashAggregate (cost=12640757.46..12713163.46 rows=385 width=720) (actual
time=1971962.023..1971962.155 rows=306 loops=1)"
" Output: bi.bus_ent_inst_name_num, bi.att_value_num_7, bi.att_value_10,
((SubPlan 1)), ((SubPlan 2)), a2.ent_inst_att_str_value, ba.att_value_1,
depto2.att_value_1, loc2.att_value_1, att_call.ent_inst_att_str_value,
att_nro.ent_inst_att_str_value, att_bis (...)"
" Group Key: bi.bus_ent_inst_name_num, bi.att_value_num_7, bi.att_value_10,
(SubPlan 1), (SubPlan 2), a2.ent_inst_att_str_value, ba.att_value_1,
depto2.att_value_1, loc2.att_value_1, att_call.ent_inst_att_str_value,
att_nro.ent_inst_att_str_value, att_bis. (...)"
" Buffers: shared hit=5817744 read=1034292 dirtied=790, local hit=2"
" -> Nested Loop (cost=4347.52..12640740.13 rows=385 width=720)
(actual time=1906401.083..1971959.176 rows=306 loops=1)"
"Output: bi.bus_ent_inst_name_num, bi.att_value_num_7,
bi.att_value_10, (SubPlan 1), (SubPlan 2), a2.ent_inst_att_str_value,
ba.att_value_1, depto2.att_value_1, loc2.att_value_1,
att_call.ent_inst_att_str_value, att_nro.ent_inst_att_str_value, att_b
(...)"
"Buffers: shared hit=5817744 read=1034292 dirtied=790, local hit=2"
"-> Hash Join (cost=4346.94..12228344.41 rows=1427 width=704)
(actual time=1906372.468..1964409.907 rows=306 loops=1)"
" Output: bi.bus_ent_inst_name_num, bi.att_value_num_7,
bi.att_value_10, ba.bus_ent_inst_id_auto, ba.att_value_1,
att_call.ent_inst_att_str_value, att_nro.ent_inst_att_str_value,
att_bis.ent_inst_att_str_value, att_pad.ent_inst_att_str_value, a (...)"
" Hash Cond: (ba.att_value_num_1 =
(bi.bus_ent_inst_name_num)::numeric)"
" Buffers: shared hit=5814458 read=1033324 dirtied=790, local
hit=2"
" -> Hash Right Join (cost=4339.65..12172907.42
rows=886647 width=158) (actual time=1906344.617..1963668.889 rows=3362294
loops=1)"
"Output: ba.bus_ent_inst_id_auto, ba.att_value_1,
ba.att_value_num_1, att_call.ent_inst_att_str_value,
att_nro.ent_inst_att_str_value, att_bis.ent_inst_att_str_value,
att_pad.ent_inst_att_str_value, att_manz.ent_inst_att_str_value, att_a
(...)"
"Hash Cond: ((att_barr.env_id = ba.env_id) AND
(att_barr.bus_ent_inst_id = ba.bus_ent_inst_id_auto))"
"Buffers: shared hit=5814458 read=1033324 dirtied=790"
"-> Index Only Scan using ix_bus_ent_inst_attr_03 on
public.bus_ent_inst_attribute att_barr (cost=0.83..1024093.06 rows=4508264
width=24) (actual time=10.435..52888.091 rows=4244011 loops=1)"
" Output: att_barr.att_id,
att_barr.ent_inst_att_str_value, att_barr.env_id, att_barr.bus_ent_inst_id,
att_barr.reg_status"
" Index Cond: (att_barr.att_id = 1115)"
" Heap Fetches: 120577"
" Buffers: shared hit=503194 read=31197 dirtied=5"
"-> Hash (cost=11101039.12..11101039.12 rows=886647
width=146) (actual time=1906329.888..1906329.888 rows=3362294 loops=1)"
" Output: ba.bus_ent_inst_id_auto, ba.att_value_1,
ba.env_id, ba.att_value_num_1, att_call.ent_inst_att_str_value,
att_nro.ent_inst_att_str_value, att_bis.ent_inst_att_str_value,
att_pad.ent_inst_att_str_value, att_manz.ent_inst_att (...)"
" Buckets: 4194304 (originally 1048576) Batches: 1
(originally 1) Memory Usage: 396824kB"
" Buffers: shared hit=5311264 read=1002127
dirtied=785"
" -> Hash Right Join
(cost=10328938.09..11101039.12 rows=886647 width=146) (actual
time=1867557.718..1904218.946 rows=3362294 loops=1)"
"Output: ba.bus_ent_inst_id_auto,
ba.att_value_1, ba.env_id, ba.att_value_num_1,
att_call.ent_inst_att_str_value, att_nro.ent_inst_att_str_value,
att_bis.ent_inst_att_str_value, att_pad.ent_inst_att_str_value,
att_manz.ent_in (...)"
"Hash Cond: ((att_apt.env_id = ba.env_id)
AND (att_apt.bus_ent_inst_id = ba.bus_ent_inst_id_auto))"
"Buffers: shared hit=5311264 read=1002127
dirtied=785"
"-> Index Only Scan using
ix_bus_ent_inst_attr_03 on public.bus_ent_inst_attribute att_apt
(cost=0.83..746958.06 rows=3287982 width=24) (actual time=0.091..32788.731
rows=3491599 loops=1)"
" Output: att_apt.att_id,
att_apt.ent_inst_att_str_value, att_apt.env_id, att_apt.bus_ent_inst_id,
att_apt.reg_status"
" Index Cond: (att_apt.att_id = 1113)"
" Heap Fetches: 88910"
" Buffers: shared hit=178090 read=25341
dirtied=5"
"-> Hash (cost=