QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------ Nested Loop (cost=0.42..8795.84 rows=11004 width=8) (actual time=0.020..12.338 rows=8919 loops=1) Join Filter: (s.m_fk = m.pk) Buffers: shared hit=8234 -> Seq Scan on m (cost=0.00..1.01 rows=1 width=8) (actual time=0.004..0.005 rows=1 loops=1) Filter: (status = 'A'::text) Buffers: shared hit=1 -> Index Scan using s_action_at_pk on s (cost=0.42..8657.28 rows=11004 width=16) (actual time=0.014..11.008 rows=8919 loops=1) Index Cond: (action_at <= '2018-09-06'::date) Filter: (status = ANY ('{A,P}'::text[])) Rows Removed by Filter: 4483 Buffers: shared hit=8233 Planning Time: 0.502 ms Execution Time: 12.793 ms (13 rows)