Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpYJl-0001EX-He for pgsql-docs@arkaria.postgresql.org; Tue, 23 Nov 2021 16:06:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mpYJi-0007gy-Fw for pgsql-docs@arkaria.postgresql.org; Tue, 23 Nov 2021 16:06:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpYJi-0007gp-82 for pgsql-docs@lists.postgresql.org; Tue, 23 Nov 2021 16:06:46 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpYJe-0004m3-Vz for pgsql-docs@postgresql.org; Tue, 23 Nov 2021 16:06:44 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D165B5C00A9; Tue, 23 Nov 2021 11:06:41 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 23 Nov 2021 11:06:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=Kejz/62LfpZaZ4T/lciqKzf7wLstNrRoWa4jVOoEy MM=; b=nOaU5f4IUlPb2L7JcQ0kL75y6NlKPdop+/M0CX6PESGCqGvBl/Qd2T8xP fSqp8mI/XloBvcNEhQRargzN3YSWsb1JwtK9VUsz4zJagXnHT/4l4Zq6fr/cI81l FAlBwyyjl0VRpS+l0dguRVMSbIkq0t3p2K+PTMyXQU/vIDiNnjcI57Sco46LIXTu 1mJs6N6sRXp0tifHmtrSJzQN9mwOtY+MtPrhmww6Ep83hrfOlcf/E8OGnqqUNYyw UumQAqvYgB/iP5s4w1zXq/QNsFezb0NQ3Olb8dRuSSLHAuJJloT3Xu/sRERQdYHO qQzJYeq6ScV7Cr/eEsVuvWdCS+Z1A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrgeeigdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeffvefgueduueelieeufeej vdfhffettddtudegvdeuuedtuddvhedvheffudejhfenucffohhmrghinhepphhoshhtgh hrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusg drtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Nov 2021 11:06:34 -0500 (EST) Message-ID: <1e9f99f9-9cdb-4bc3-85d9-c017fbc54566@enterprisedb.com> Date: Tue, 23 Nov 2021 17:06:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: ORDER BY in materialized view example? Content-Language: en-US To: Maciek Sakrejda , pgsql-docs@postgresql.org References: From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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? > > But it seems like the ORDER BY should either be explained or dropped: as > is, this gives the impression that the ORDER BY can be "embedded" into > the resulting relation and persist to other queries that do not include > an explicit ORDER BY. (I recently ran across this belief, though not > sure if this was due to this example.) > > Thoughts? > > [1]: > https://www.postgresql.org/docs/current/rules-materializedviews.html > 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.