Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
REFRESH ...IZED VIEW(7)   PostgreSQL 18.4 Documentation  REFRESH ...IZED VIEW(7)

NAME
     REFRESH_MATERIALIZED_VIEW - replace the contents of a materialized view

SYNOPSIS
     REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name
	 [ WITH [ NO ] DATA ]

DESCRIPTION
     REFRESH  MATERIALIZED  VIEW completely replaces the contents of a material-
     ized view. To execute this command you must have the MAINTAIN privilege  on
     the  materialized	view.  The  old  contents are discarded. If WITH DATA 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 WITH NO
     DATA is specified no new data is generated and  the  materialized	view  is
     left in an unscannable state.

     CONCURRENTLY and WITH NO DATA may not be specified together.

PARAMETERS
     CONCURRENTLY
	 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 ma-
	 terialized view. This option may be faster in cases where a small  num-
	 ber of rows are affected.

	 This  option  is  only allowed if there is at least one UNIQUE 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 WHERE
	 clause.

	 This option can only be used when the materialized view is already pop-
	 ulated.

	 Even with this option only one REFRESH at a time may  run  against  any
	 one materialized view.

     name
	 The  name (optionally schema-qualified) of the materialized view to re-
	 fresh.

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

     While REFRESH MATERIALIZED VIEW is running, the search_path is  temporarily
     changed to pg_catalog, pg_temp.

EXAMPLES
     This  command will replace the contents of the materialized view called or-
     der_summary using the query from the materialized	view's	definition,  and
     leave it in a scannable state:

	 REFRESH MATERIALIZED VIEW order_summary;

     This  command  will  free storage associated with the materialized view an-
     nual_statistics_basis and leave it in an unscannable state:

	 REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA;

COMPATIBILITY
     REFRESH MATERIALIZED VIEW is a PostgreSQL extension.

SEE ALSO
     CREATE MATERIALIZED VIEW (CREATE_MATERIALIZED_VIEW(7)), ALTER  MATERIALIZED
     VIEW  (ALTER_MATERIALIZED_VIEW(7)),  DROP MATERIALIZED VIEW (DROP_MATERIAL-
     IZED_VIEW(7))

PostgreSQL 18.4 		      2026		 REFRESH ...IZED VIEW(7)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=REFRESH_MATERIALIZED_VIEW&sektion=7&manpath=FreeBSD+Ports+15.1.quarterly>

home | help