3 ms·
How often does rails refresh the materialized views? And is it automatic or do you have to explicitly refresh them?
by geori 7y ago
How often does rails refresh the materialized views? And is it automatic or do you have to explicitly refresh them?
- lfittl 7y agoYou typically do it on a schedule, e.g. once per hour, or once every day. In the post the whenever gem (https://github.com/javan/whenever https://github.com/javan/whenever) is used, but you could use anything that is able to run things periodically. If you'd want to stay solely within Postgres, there is also pg_cron (https://github.com/citusdata/pg_cron https://github.com/citusdata/pg_cron) which could be used to call REFRESH MATERIALIZED VIEW from within the database.
- wefarrell 7y agoThe post covers this under the section "Refreshing a materialized view".
- toasterlovin 7y agoIn addition to what the other commenters mentioned, if you’re importing data, you can refresh the affected materialized views after the data import is complete.