From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 29 Nov 2021 17:13:13 +0000 (-0500)
Subject: Doc: improve documentation about ORDER BY in matviews.
X-Git-Tag: REL_10_20~59
X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=514f0ae4f40f322b1a10bd774abd4b4d01c97a99;p=postgresql.git

Doc: improve documentation about ORDER BY in matviews.

Remove the confusing use of ORDER BY in an example materialized
view.  It adds nothing to the example, but might encourage
people to follow bad practice.  Clarify REFRESH MATERIALIZED
VIEW's note about whether view ordering is retained (it isn't).

Maciek Sakrejda

Discussion: https://postgr.es/m/CAOtHd0D-OvrUU0C=4hX28p4BaSE1XL78BAQ0VcDaLLt8tdUzsg@mail.gmail.com
---

diff --git a/doc/src/sgml/ref/refresh_materialized_view.sgml b/doc/src/sgml/ref/refresh_materialized_view.sgml
index 82d1628e802..86bf5c462b6 100644
--- a/doc/src/sgml/ref/refresh_materialized_view.sgml
+++ b/doc/src/sgml/ref/refresh_materialized_view.sgml
@@ -93,12 +93,10 @@ REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <replaceable class="PARAMETER">name</
   <title>Notes</title>
 
   <para>
-   While the default index for future
-   <xref linkend="SQL-CLUSTER">
-   operations is retained, <command>REFRESH MATERIALIZED VIEW</> does not
-   order the generated rows based on this property. If you want the data
-   to be ordered upon generation, you must use an <literal>ORDER BY</>
-   clause in the backing query.
+   If there is an <literal>ORDER BY</literal> clause in the materialized
+   view's defining query, the original contents of the materialized view
+   will be ordered that way; but <command>REFRESH MATERIALIZED
+   VIEW</command> does not guarantee to preserve that ordering.
   </para>
  </refsect1>
 
diff --git a/doc/src/sgml/rules.sgml b/doc/src/sgml/rules.sgml
index 5c30e361d42..8da83715681 100644
--- a/doc/src/sgml/rules.sgml
+++ b/doc/src/sgml/rules.sgml
@@ -956,9 +956,6 @@ CREATE MATERIALIZED VIEW sales_summary AS
     FROM invoice
     WHERE invoice_date < CURRENT_DATE
     GROUP BY
-      seller_no,
-      invoice_date
-    ORDER BY
       seller_no,
       invoice_date;