From 4f33af23e7e3ac30b3cb9480981c3accf401ef01 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 29 Nov 2021 12:13:12 -0500 Subject: [PATCH] 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 --- doc/src/sgml/ref/refresh_materialized_view.sgml | 10 ++++------ doc/src/sgml/rules.sgml | 3 --- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ref/refresh_materialized_view.sgml b/doc/src/sgml/ref/refresh_materialized_view.sgml index 3bf8884447..675d6090f3 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 ] nameNotes - While the default index for future - CLUSTER - 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. diff --git a/doc/src/sgml/rules.sgml b/doc/src/sgml/rules.sgml index 6065b1c2a3..4aa4e00e01 100644 --- a/doc/src/sgml/rules.sgml +++ b/doc/src/sgml/rules.sgml @@ -961,9 +961,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;