]> begriffs open source - ai-pg/blob - full-docs/txt/sql-refreshmaterializedview.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-refreshmaterializedview.txt
1
2 REFRESH MATERIALIZED VIEW
3
4    REFRESH MATERIALIZED VIEW — replace the contents of a materialized view
5
6 Synopsis
7
8 REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name
9     [ WITH [ NO ] DATA ]
10
11 Description
12
13    REFRESH MATERIALIZED VIEW completely replaces the contents of a
14    materialized view. To execute this command you must have the MAINTAIN
15    privilege on the materialized view. The old contents are discarded. If
16    WITH DATA is specified (or defaults) the backing query is executed to
17    provide the new data, and the materialized view is left in a scannable
18    state. If WITH NO DATA is specified no new data is generated and the
19    materialized view is left in an unscannable state.
20
21    CONCURRENTLY and WITH NO DATA may not be specified together.
22
23 Parameters
24
25    CONCURRENTLY
26           Refresh the materialized view without locking out concurrent
27           selects on the materialized view. Without this option a refresh
28           which affects a lot of rows will tend to use fewer resources and
29           complete more quickly, but could block other connections which
30           are trying to read from the materialized view. This option may
31           be faster in cases where a small number of rows are affected.
32
33           This option is only allowed if there is at least one UNIQUE
34           index on the materialized view which uses only column names and
35           includes all rows; that is, it must not be an expression index
36           or include a WHERE clause.
37
38           This option can only be used when the materialized view is
39           already populated.
40
41           Even with this option only one REFRESH at a time may run against
42           any one materialized view.
43
44    name
45           The name (optionally schema-qualified) of the materialized view
46           to refresh.
47
48 Notes
49
50    If there is an ORDER BY clause in the materialized view's defining
51    query, the original contents of the materialized view will be ordered
52    that way; but REFRESH MATERIALIZED VIEW does not guarantee to preserve
53    that ordering.
54
55    While REFRESH MATERIALIZED VIEW is running, the search_path is
56    temporarily changed to pg_catalog, pg_temp.
57
58 Examples
59
60    This command will replace the contents of the materialized view called
61    order_summary using the query from the materialized view's definition,
62    and leave it in a scannable state:
63 REFRESH MATERIALIZED VIEW order_summary;
64
65    This command will free storage associated with the materialized view
66    annual_statistics_basis and leave it in an unscannable state:
67 REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA;
68
69 Compatibility
70
71    REFRESH MATERIALIZED VIEW is a PostgreSQL extension.
72
73 See Also
74
75    CREATE MATERIALIZED VIEW, ALTER MATERIALIZED VIEW, DROP MATERIALIZED
76    VIEW