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 1muWqP-0002qt-DT for pgsql-general@arkaria.postgresql.org; Tue, 07 Dec 2021 09:33:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1muWqO-0001Uq-3y for pgsql-general@arkaria.postgresql.org; Tue, 07 Dec 2021 09:33:04 +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 1muWqN-0001Ug-PR for pgsql-general@lists.postgresql.org; Tue, 07 Dec 2021 09:33:03 +0000 Received: from mail.gavagai.nl ([5.135.160.52]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muWqH-0008Em-3e for pgsql-general@lists.postgresql.org; Tue, 07 Dec 2021 09:33:02 +0000 Received: from tipi (ns3002999.ip-151-80-42.eu [151.80.42.145]) by mail.gavagai.nl (MAIL-O-TRON) with ESMTPSA id A7291E9C1CF; Tue, 7 Dec 2021 10:32:53 +0100 (CET) Date: Tue, 7 Dec 2021 10:32:51 +0100 From: Wicher To: "Phil Endecott" Cc: Subject: Re: Advice on using materialized views Message-ID: <20211207103251.59354436@tipi> In-Reply-To: <1638816527952@dmwebmail.dmwebmail.chezphil.org> References: <1638816527952@dmwebmail.dmwebmail.chezphil.org> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 06 Dec 2021 18:48:47 +0000 "Phil Endecott" wrote: > and > I need to modify the definition of a view that filters the "new" > values from the raw table each time the materialised view is > refreshed. You won't necessarily need to rewrite the "recent data" view definitions, I think. What is deemed "recent" depends on what's in the materialized views (it'd be anything newer than whatever is in there). The good news is that you can simply query for that :-) So trivially, in your "the data that is more recent than the stuff from the materialized views" non-materialized view you'd use a definition like SELECT .... WHERE sometimestamp > (select max(sometimestamp) from the_materialized_view) or something along those lines.