btw saya pakai rails, kalau di explain hasilnya ini :
Gather (cost=258675.86..823834.23 rows=142148 width=388)
Workers Planned: 2
-> Merge Join (cost=257675.86..808619.43 rows=59228 width=388)
-> Nested Loop (cost=1.29..1672403.86 rows=166675 width=388)
-> Parallel Index Scan using index_entities_on_id on entities (cost=0.42..35122.66 rows=333356 width=388)
-> Bitmap Heap Scan on transactions (cost=0.86..4.89 rows=2 width=8)
-> BitmapOr (cost=0.86..0.86 rows=2 width=0)
-> Bitmap Index Scan on index_transactions_on_originator_id (cost=0.00..0.43 rows=1 width=0)
-> Bitmap Index Scan on index_transactions_on_beneficiary_id (cost=0.00..0.43 rows=1 width=0)
-> Materialize (cost=257654.50..259076.01 rows=284301 width=4)
-> Sort (cost=257654.50..258365.25 rows=284301 width=4)
Sort Key: risks.entity_id
-> Bitmap Heap Scan on risks (cost=7771.89..228012.51 rows=284301 width=4)
Recheck Cond: ((observable)::text = 'segmentation'::text)
-> Bitmap Index Scan on index_risks_on_observable_and_entity_id (cost=0.00..7700.82 rows=284301 width=0)
Index Cond: ((observable)::text = 'segmentation'::text)