2 .\" Title: REFRESH MATERIALIZED VIEW
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "REFRESH MATERIALIZED VIEW" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 REFRESH_MATERIALIZED_VIEW \- replace the contents of a materialized view
35 REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] \fIname\fR
40 \fBREFRESH MATERIALIZED VIEW\fR
41 completely replaces the contents of a materialized view\&. To execute this command you must have the
43 privilege on the materialized view\&. The old contents are discarded\&. If
45 is specified (or defaults) the backing query is executed to provide the new data, and the materialized view is left in a scannable state\&. If
47 is specified no new data is generated and the materialized view is left in an unscannable state\&.
52 may not be specified together\&.
57 Refresh the materialized view without locking out concurrent selects on the materialized view\&. Without this option a refresh which affects a lot of rows will tend to use fewer resources and complete more quickly, but could block other connections which are trying to read from the materialized view\&. This option may be faster in cases where a small number of rows are affected\&.
59 This option is only allowed if there is at least one
61 index on the materialized view which uses only column names and includes all rows; that is, it must not be an expression index or include a
65 This option can only be used when the materialized view is already populated\&.
67 Even with this option only one
69 at a time may run against any one materialized view\&.
74 The name (optionally schema\-qualified) of the materialized view to refresh\&.
80 clause in the materialized view\*(Aqs defining query, the original contents of the materialized view will be ordered that way; but
81 \fBREFRESH MATERIALIZED VIEW\fR
82 does not guarantee to preserve that ordering\&.
85 \fBREFRESH MATERIALIZED VIEW\fR
88 is temporarily changed to
89 pg_catalog, pg_temp\&.
92 This command will replace the contents of the materialized view called
94 using the query from the materialized view\*(Aqs definition, and leave it in a scannable state:
100 REFRESH MATERIALIZED VIEW order_summary;
106 This command will free storage associated with the materialized view
107 annual_statistics_basis
108 and leave it in an unscannable state:
114 REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA;
121 \fBREFRESH MATERIALIZED VIEW\fR
126 CREATE MATERIALIZED VIEW (\fBCREATE_MATERIALIZED_VIEW\fR(7)), ALTER MATERIALIZED VIEW (\fBALTER_MATERIALIZED_VIEW\fR(7)), DROP MATERIALIZED VIEW (\fBDROP_MATERIALIZED_VIEW\fR(7))