activerecord-multi-tenant icon indicating copy to clipboard operation
activerecord-multi-tenant copied to clipboard

Possible to lazily load tenant in sidekiq middleware?

Open eapache-opslevel opened this issue 9 months ago • 0 comments

First, thanks for such a useful gem!

We have a setup where we run a lot of sidekiq jobs using the middleware from this gem. They are all tenant-scoped, but a lot of them never actually need the tenant object itself, just the ID (to attach as a where clause to other queries).

We have found that our database is doing a fair bit of extra work loading the tenant object in all of these jobs (not because the query is expensive, but because of the volume of jobs we run), which is ultimately unused. We were hoping there was a way to make the sidekiq middleware load the tenant object lazily? Or the ability to flag jobs as not needing the full object, and just using the ID from the job args (in the way that MultiTenant.with(id) is already supported) or something?

eapache-opslevel avatar May 22 '24 13:05 eapache-opslevel