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 1mrcsc-0005Oe-KG for pgsql-general@arkaria.postgresql.org; Mon, 29 Nov 2021 09:23:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mrcsb-0008UX-EP for pgsql-general@arkaria.postgresql.org; Mon, 29 Nov 2021 09:23:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrcsb-0008UO-3m for pgsql-general@lists.postgresql.org; Mon, 29 Nov 2021 09:23:21 +0000 Received: from mail.gavagai.nl ([5.135.160.52]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrcsY-0005QM-TJ for pgsql-general@lists.postgresql.org; Mon, 29 Nov 2021 09:23:20 +0000 Received: from tipi (ns3002999.ip-151-80-42.eu [151.80.42.145]) by mail.gavagai.nl (MAIL-O-TRON) with ESMTPSA id 01C1DDE81DE for ; Mon, 29 Nov 2021 10:23:16 +0100 (CET) Date: Mon, 29 Nov 2021 10:23:15 +0100 From: Wicher To: pgsql-general Subject: DDL tools for working with views in dependency order? Message-ID: <20211129102315.058595fe@tipi> 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=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, As part of analysis pipelines I'm dealing with stacks/trees of views =E2=80= =94 views selecting from other views, often recombining it with table data =E2=80=94 which at t= imes undergo heavy development. This often requires changing/discarding/renaming/=E2=80=A6 a v= iew or many views somewhere in the middle of the stack. Depending on whether the type signatu= re of the view is changing, a CREATE OR REPLACE to mutate views "in-place" may not be poss= ible, so doing refactoring often requires dropping & recreating views dependent on the mut= ated views. Are there tools out there which allow for easily doing such work - rebuildi= ng parts of the dependency-tree of views as needed? I'm looking for something = more convenient than "put your view DDL statements in a carefully ordered & manually refere= nce-checked .sql file". I also want to have the state of the view tree outside of the d= atabase and maintain/version it in concert with application code. Furthermore, some of the views in the tree are materialized, and I'd like t= o be able to issue some sort of "cascading refresh" at my convenience (so, not through a= trigger), that is, refresh all materialized views that directly or indirectly depend on da= ta sourced from certain tables (by-table resolution would be high enough, by-column resolut= ion is not necessary), and do so in dependency-order. Are there tools out there that a= llow me to do such? I'm currently working on my own spin on solving this mundane-sounding probl= em, and I'm curious towards any existing approaches and any PostgreSQL-native primitive= s that may be of aid. Please share your thoughts and comments! Thanks and regards, Wicher