Commit ce43b3dc authored by Tom Lane's avatar Tom Lane

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
parent 1b1e4bfe
...@@ -93,12 +93,10 @@ REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <replaceable class="parameter">name</ ...@@ -93,12 +93,10 @@ REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <replaceable class="parameter">name</
<title>Notes</title> <title>Notes</title>
<para> <para>
While the default index for future If there is an <literal>ORDER BY</literal> clause in the materialized
<link linkend="sql-cluster"><command>CLUSTER</command></link> view's defining query, the original contents of the materialized view
operations is retained, <command>REFRESH MATERIALIZED VIEW</command> does not will be ordered that way; but <command>REFRESH MATERIALIZED
order the generated rows based on this property. If you want the data VIEW</command> does not guarantee to preserve that ordering.
to be ordered upon generation, you must use an <literal>ORDER BY</literal>
clause in the backing query.
</para> </para>
</refsect1> </refsect1>
......
...@@ -961,9 +961,6 @@ CREATE MATERIALIZED VIEW sales_summary AS ...@@ -961,9 +961,6 @@ CREATE MATERIALIZED VIEW sales_summary AS
FROM invoice FROM invoice
WHERE invoice_date &lt; CURRENT_DATE WHERE invoice_date &lt; CURRENT_DATE
GROUP BY GROUP BY
seller_no,
invoice_date
ORDER BY
seller_no, seller_no,
invoice_date; invoice_date;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment