QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=1900.77..6768.34 rows=11004 width=8) (actual time=1.345..11.812 rows=8919 loops=1) Join Filter: (s.m_fk = m.pk) Buffers: shared hit=3184 -> Seq Scan on m (cost=0.00..1.01 rows=1 width=8) (actual time=0.005..0.006 rows=1 loops=1) Filter: (status = 'A'::text) Buffers: shared hit=1 -> Bitmap Heap Scan on s (cost=1900.77..6629.78 rows=11004 width=16) (actual time=1.337..10.515 rows=8919 loops=1) Recheck Cond: ((action_at <= '2018-09-06'::date) AND (status = ANY ('{P,PD,A}'::text[]))) Filter: (status = ANY ('{A,P}'::text[])) Rows Removed by Filter: 4483 Heap Blocks: exact=3129 Buffers: shared hit=3183 -> Bitmap Index Scan on s_action_at_pk (cost=0.00..1898.02 rows=82347 width=0) (actual time=0.995..0.995 rows=13402 loops=1) Index Cond: (action_at <= '2018-09-06'::date) Buffers: shared hit=54 Planning Time: 0.719 ms Execution Time: 12.288 ms (17 rows)