refresh materialized view periodically postgres

自作多情 提交于 2019-12-19 05:51:11

问题


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:

  1. what's the best way to refresh a materialized view?
  2. 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


回答1:


the best way is to execute periodically a script that does the task:

the script is:

#!/bin/sh
psql -U user_name -d database_instance_name -c 'refresh materialized view view_name'

and add an entry in the crontab like:

@hourly  /full_path/script_name.sh


来源:https://stackoverflow.com/questions/47012961/refresh-materialized-view-periodically-postgres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!