for optimization purposes I'm using a materialized view, to refresh it periodically I have set a cron job that runs each period t in my case every three hours. my questions are:
- what's the best way to refresh a materialized view?
- what can go wrong if using a cron job to refresh a materialized view?
I have come across a postgres plugin that schedule jobs link
the best way is to execute periodically a script that does the task:
the script is:
and add an entry in the crontab like: