Doc: improve documentation about ORDER BY in matviews.
authorTom Lane
Mon, 29 Nov 2021 17:13:13 +0000 (12:13 -0500)
committerTom Lane
Mon, 29 Nov 2021 17:13:13 +0000 (12:13 -0500)
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

doc/src/sgml/ref/refresh_materialized_view.sgml
doc/src/sgml/rules.sgml

index 8ae62671adab9afffa716840982266228ebe5606..675d6090f3cd68b17da2ccfa1db851641795b47e 100644 (file)
@@ -93,12 +93,10 @@ REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name
   Notes
 
   
-   While the default index for future
-   
-   operations is retained, 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 ORDER BY
-   clause in the backing query.
+   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.
   
  
 
index 6b0dc41615cf2fc9b4d3e2c3a8e4ae79695155d4..e7fc022c6b3f3a74ebbc2b454001dbe6cdc317cc 100644 (file)
@@ -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;