我试图运行REFRESH MATERIALIZED VIEW CONCURRENTLY recipe_search;
,但PostgreSQL给了我这个错误:ERROR 55000 (object_not_in_prerequisite_state): cannot refresh materialized view "public.recipe_search" concurrently
。
有问题的物化视图在psql
中显示如下:
# \d recipe_search
Materialized view "public.recipe_search"
Column | Type | Modifiers
----------+------------------------+-----------
id | integer |
title | character varying(255) |
document | tsvector |
Indexes:
"recipe_search_document_index" gin (document)
"recipe_search_title_trgm_index" gin (title gin_trgm_ops)
为什么我不能同时刷新它?
答案 0 :(得分:1)
实体化视图无法刷新CONCURRENTLY
,除非它至少有一个唯一索引,如文档中所述:
CONCURRENTLY
...只有在物化视图中至少有一个UNIQUE索引只允许使用列名并包含所有行时,才允许使用此选项。也就是说,它不能索引任何表达式,也不能包含WHERE子句。
https://www.postgresql.org/docs/9.6/static/sql-refreshmaterializedview.html