From cc1965a99bf87005f431804bbda0f723887a04d6 Mon Sep 17 00:00:00 2001 From: Kevin Grittner Date: Tue, 16 Jul 2013 12:55:44 -0500 Subject: Add support for REFRESH MATERIALIZED VIEW CONCURRENTLY. This allows reads to continue without any blocking while a REFRESH runs. The new data appears atomically as part of transaction commit. Review questioned the Assert that a matview was not a system relation. This will be addressed separately. Reviewed by Hitoshi Harada, Robert Haas, Andres Freund. Merged after review with security patch f3ab5d4. --- doc/src/sgml/mvcc.sgml | 3 +-- doc/src/sgml/ref/refresh_materialized_view.sgml | 34 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml index 316add70b70..cefd3235a6b 100644 --- a/doc/src/sgml/mvcc.sgml +++ b/doc/src/sgml/mvcc.sgml @@ -928,8 +928,7 @@ ERROR: could not serialize access due to read/write dependencies among transact - This lock mode is not automatically acquired on tables by any - PostgreSQL command. + Acquired by REFRESH MATERIALIZED VIEW CONCURRENTLY. diff --git a/doc/src/sgml/ref/refresh_materialized_view.sgml b/doc/src/sgml/ref/refresh_materialized_view.sgml index 8f59bbf1231..d2f8104aa7d 100644 --- a/doc/src/sgml/ref/refresh_materialized_view.sgml +++ b/doc/src/sgml/ref/refresh_materialized_view.sgml @@ -21,7 +21,7 @@ PostgreSQL documentation -REFRESH MATERIALIZED VIEW name +REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name [ WITH [ NO ] DATA ] @@ -38,12 +38,44 @@ REFRESH MATERIALIZED VIEW name 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 + materialized view. This option may be faster in cases where a small + number 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 index on any + expressions nor include a WHERE clause. + + + This option may not be used when the materialized view is not already + populated. + + + Even with this option only one REFRESH at a time may + run against any one materialized view. + + + + name -- cgit v1.2.3