Re: ORDER BY in materialized view example?
Jonathan S. Katz <jkatz@postgresql.org>
From: "Jonathan S. Katz" <jkatz@postgresql.org>
To: Tom Lane <tgl@sss.pgh.pa.us>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: Maciek Sakrejda <m.sakrejda@gmail.com>, pgsql-docs@postgresql.org
Date: 2021-11-23T18:11:08Z
Lists: pgsql-docs
On 11/23/21 12:44 PM, Tom Lane wrote: > Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes: >> On 23.11.21 07:18, Maciek Sakrejda wrote: >>> An example in the materialized view documentation [1] includes an ORDER >>> BY clause without a clear reason. Does it help build the index more >>> efficiently? I suppose it's also sort of like a CLUSTER? > >> I agree the ORDER BY is not relevant to the example. There might be >> some implementation-dependent advantage to ordering a materialized view, >> but if there is, it isn't explained in the example. > > Yeah. It would result in the initial contents of the matview being > ordered, but I'm sure we don't wish to guarantee that REFRESH would > preserve that. I'm on board with just removing the ORDER BY from > that example. +1 > I'd rather say something like > > If there is an ORDER BY clause in the matview's defining query, > the original contents of the matview will be ordered that way; > but REFRESH MATERIALIZED VIEW does not guarantee to preserve > that ordering. +1. I think I got bit by this in the real world years back. The above comment is pretty clear. Thanks, Jonathan
Commits
-
Doc: improve documentation about ORDER BY in matviews.
- ce43b3dc52c9 14.2 landed
- a7359913a1c2 13.6 landed
- 514f0ae4f40f 10.20 landed
- 3f43dcc1c686 11.15 landed
- 2f908e1a3b9c 12.10 landed
- 4f33af23e7e3 15.0 landed