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 1lsfeV-0008Vt-LM for pgsql-admin@arkaria.postgresql.org; Mon, 14 Jun 2021 06:00:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lsfeU-0003wR-K6 for pgsql-admin@arkaria.postgresql.org; Mon, 14 Jun 2021 06:00:50 +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 1lsfeU-0003wI-BK for pgsql-admin@lists.postgresql.org; Mon, 14 Jun 2021 06:00:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lsfeR-0004K9-CV for pgsql-admin@postgresql.org; Mon, 14 Jun 2021 06:00:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15E60iIN162830; Mon, 14 Jun 2021 02:00:44 -0400 From: Tom Lane To: Wells Oliver cc: pgsql-admin Subject: Re: pg_restore can't re-mat mat view that uses a function which depends on another mat view In-reply-to: References: Comments: In-reply-to Wells Oliver message dated "Sun, 13 Jun 2021 15:15:59 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <162828.1623650444.1@sss.pgh.pa.us> Date: Mon, 14 Jun 2021 02:00:44 -0400 Message-ID: <162829.1623650444@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Wells Oliver writes: > Odd one here, but after restoring a database in parallel, I notice a few > mat views are unmaterialized, e.g. > ... > The reason being is that vwm_ytd_p uses a function age() which queries from > vwm_info, which has not yet been materialized. In fact, it is being > materialized in parallel in another job, so not yet available. Right. > Anything to do here? Not much we can do today. User-defined functions are black boxes, so pg_dump can't see what their innards might reference. v14 will have the ability to declare SQL functions in something closer to SQL-spec syntax, in which the body of the function will be parsed at definition time. With that style of function, pg_dump *does* see the dependencies so this sort of thing should work. That approach is not without some downsides, but it sounds like it'd improve your case here. regards, tom lane