我在Postgres 9.4数据库中有这个物化视图:
Materialized view "public.v_videolist"
Column | Type | Modifiers | Storage | Stats target | Description
----------+---------+-----------+----------+--------------+-------------
id | integer | | plain | |
title | text | | extended | |
embed | text | | extended | |
img | text | | extended | |
imgs | text | | extended | |
tags | text | | extended | |
category | text | | extended | |
vid | bigint | | plain | |
views | bigint | | plain | |
likes | bigint | | plain | |
unlikes | bigint | | plain | |
duration | integer | | plain | |
site | integer | | plain | |
Indexes:
"i_vl_id" UNIQUE, btree (id)
View definition:
SELECT videolist.id,
videolist.title,
videolist.embed,
videolist.img,
videolist.imgs,
videolist.tags,
videolist.category,
videolist.vid,
videolist.views,
videolist.likes,
videolist.unlikes,
videolist.duration,
videolist.site
FROM videolist
ORDER BY random();
此视图有时会自行刷新。没有cron工作来刷新它或类似的东西。它不时会自行刷新,我无法找到谁做到了。我完全记录了所有查询。日志中没有任何refresh materialized view
。
为什么我的观点会更新?有什么建议吗?
答案 0 :(得分:0)
可以使用此SQL语句安排作业更新统计信息:
REFRESH MATERIALIZED VIEW public.v_videolist;
您可以使用pg_cron
来安排工作。