I'm in the final stages of an MVP for a new pet project... and trying to improve the query times.
My primary table currently has about 150k records... and that's expected to grow to well over 1million... perhaps even 10million plus. These records belong to a parent that can be blocked by the user. When the parent is blocked, the child should no longer be visible in any views until the parent is unblocked. Users can have upwards of 100 or more blocked parents...
At the moment, I have a scope that receives an array of blocked parent_ids...
scope :parent_filter, ->(parent_ids) { where.not(parent_id: [*parent_ids]) }
The parent_id is indexed in the child table.
This is resulting in query times of about 250-350ms.... Is there a better way to do this? I was thinking perhaps a 3 way join with the parent and parent_child table might be better... but not sure.
If it makes a difference, I'm on the $7 Dyno & $9 Postgres right now... Any help would be appreciated!