You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I was investigating why some of our report generations take a long time. We use soft deletion in some tables with discard gem.
We iterate over bunch of records and we suffer from N+1 queries (but that's different problem). However, when loading associated records - Active Record does not add where discarded_at is NULL to WHERE clause. And because of that - index on foreign key column is not used. These indexes have condition - suggested by Active Record Doctor - where discarded_at is NULL. So in the end - table was full scanned.
What do you think about - either disabling that check or at least adding some info about that to documentation?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Recently I was investigating why some of our report generations take a long time. We use soft deletion in some tables with
discardgem.We iterate over bunch of records and we suffer from N+1 queries (but that's different problem). However, when loading associated records - Active Record does not add
where discarded_at is NULLtoWHEREclause. And because of that - index on foreign key column is not used. These indexes have condition - suggested by Active Record Doctor -where discarded_at is NULL. So in the end - table was full scanned.What do you think about - either disabling that check or at least adding some info about that to documentation?
Beta Was this translation helpful? Give feedback.
All reactions