2017-01-11 70 views
1

我有這個物化視圖在我的Postgres數據庫9.4:PostgreSQL的物化視圖是由自身刷新

    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

的作業可以安排更新使用這條SQL語句的統計數據:

REFRESH MATERIALIZED VIEW public.v_videolist; 

您可以使用pg_cron調度工作。