1REFRESH MATERIALIZED VIEW(P7o)stgreSQL 14.3 DocumentatRiEoFnRESH MATERIALIZED VIEW(7)
2
3
4

NAME

6       REFRESH_MATERIALIZED_VIEW - replace the contents of a materialized view
7

SYNOPSIS

9       REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name
10           [ WITH [ NO ] DATA ]
11

DESCRIPTION

13       REFRESH MATERIALIZED VIEW completely replaces the contents of a
14       materialized view. To execute this command you must be the owner of the
15       materialized view. The old contents are discarded. If WITH DATA is
16       specified (or defaults) the backing query is executed to provide the
17       new data, and the materialized view is left in a scannable state. If
18       WITH NO DATA is specified no new data is generated and the materialized
19       view is left in an unscannable state.
20
21       CONCURRENTLY and WITH NO DATA may not be specified together.
22

PARAMETERS

24       CONCURRENTLY
25           Refresh the materialized view without locking out concurrent
26           selects on the materialized view. Without this option a refresh
27           which affects a lot of rows will tend to use fewer resources and
28           complete more quickly, but could block other connections which are
29           trying to read from the materialized view. This option may be
30           faster in cases where a small number of rows are affected.
31
32           This option is only allowed if there is at least one UNIQUE index
33           on the materialized view which uses only column names and includes
34           all rows; that is, it must not be an expression index or include a
35           WHERE clause.
36
37           This option may not be used when the materialized view is not
38           already populated.
39
40           Even with this option only one REFRESH at a time may run against
41           any one materialized view.
42
43       name
44           The name (optionally schema-qualified) of the materialized view to
45           refresh.
46

NOTES

48       If there is an ORDER BY clause in the materialized view's defining
49       query, the original contents of the materialized view will be ordered
50       that way; but REFRESH MATERIALIZED VIEW does not guarantee to preserve
51       that ordering.
52

EXAMPLES

54       This command will replace the contents of the materialized view called
55       order_summary using the query from the materialized view's definition,
56       and leave it in a scannable state:
57
58           REFRESH MATERIALIZED VIEW order_summary;
59
60       This command will free storage associated with the materialized view
61       annual_statistics_basis and leave it in an unscannable state:
62
63           REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA;
64

COMPATIBILITY

66       REFRESH MATERIALIZED VIEW is a PostgreSQL extension.
67

SEE ALSO

69       CREATE MATERIALIZED VIEW (CREATE_MATERIALIZED_VIEW(7)), ALTER
70       MATERIALIZED VIEW (ALTER_MATERIALIZED_VIEW(7)), DROP MATERIALIZED VIEW
71       (DROP_MATERIALIZED_VIEW(7))
72
73
74
75PostgreSQL 14.3                      2022         REFRESH MATERIALIZED VIEW(7)
Impressum