influitive / apartment

Database multi-tenancy for Rack (and Rails) applications
2.68k stars 460 forks source link

How to configure use_schema_cache_dump with apartment gem? #683

Closed rohangrg closed 5 months ago

rohangrg commented 5 months ago

We are using apartment gem, and recently we changed our passenger config to restart a process whenever it hits request count of 400.

SELECT a.attname
FROM (  SELECT indrelid, indkey, generate_subscripts(  indkey, $1) idx
    FROM pg_index
    WHERE indrelid  = $2::regclass
AND  indisprimary  ) i  JOIN  pg_attribute a  ON a.attrelid  = i.indrelid  AND a.attnum =  i.indkey[i.idx]  ORDER BY i.idx

Due to which, the above query is getting called multiple times, which is called whenever the process is started/restarted.

I read some post online Issue URL and found out that this can be avoided if enabled use_schema_cache_dump in my rails application. Solution they suggested Solution

But will it work with apartment gem? Since each tenant can have different schema.