Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIgo0-00A5PV-J8 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Dec 2023 03:11:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rIgnx-00C1tb-VN for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Dec 2023 03:11:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIgnw-00C1rU-Vo for pgsql-hackers@lists.postgresql.org; Thu, 28 Dec 2023 03:11:29 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIgnt-00CXOe-RN for pgsql-hackers@lists.postgresql.org; Thu, 28 Dec 2023 03:11:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=gbQc3zBNKXWUnlLaW3fekodBSHR/Wfh1BIij3k3s36U=; b=iQcoe iE5+35HK33safNP+2FMTJ/pCX+j65eQBIT7oboRYIDWjJRywF5jiUjManNLuAAJPZR7fTJI1uW+a9 kal8i3X2yj4WXjMEgM/D4rvQkndWlKzjwZUb69d6HFfxK7yxCIb3lB4OTzdY+omwXesfsakAZAEuU /jJrhCQdzHjJe8fVfeHOL+P4BlQWJ4Pw3N2yTLlO5VZvp1ApVg1req6GZFZFVuRbQTM5IV4ITbmvY +qIaeU7SsXLjKMKq8gaquLhGzLsHfJqvE6KY7duWTxMW9tXuIuWDykSSThZkKPyvJWn9gNSA3hzWL PGLOdU8eq8+5iWiaahAEMt2VCdKuA==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1rIgnr-005E7l-2F; Wed, 27 Dec 2023 22:11:23 -0500 Date: Wed, 27 Dec 2023 22:11:23 -0500 From: Bruce Momjian To: Corey Huinker Cc: Tomas Vondra , Ashutosh Bapat , pgsql-hackers@lists.postgresql.org Subject: Re: Statistics Import and Export Message-ID: References: <76596388-6fe6-0baf-351d-734458a46d76@enterprisedb.com> <4268d862-7784-f76f-d7f1-359b0b4db67c@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Dec 27, 2023 at 09:41:31PM -0500, Corey Huinker wrote: > When I thought about the ability to dump/load statistics in the past, I > usually envisioned some sort of DDL that would do the export and import. > So for example we'd have EXPORT STATISTICS / IMPORT STATISTICS commands, > or something like that, and that'd do all the work. This would mean > stats are "first-class citizens" and it'd be fairly straightforward to > add this into pg_dump, for example. Or at least I think so ... > > Alternatively we could have the usual "functional" interface, with a > functions to export/import statistics, replacing the DDL commands. > > Unfortunately, none of this works for the pg_upgrade use case, because > existing cluster versions would not support this new interface, of > course. That's a significant flaw, as it'd make this useful only for > upgrades of future versions. > > > This was the reason I settled on the interface that I did: while we can create > whatever interface we want for importing the statistics, we would need to be > able to extract stats from databases using only the facilities available in > those same databases, and then store that in a medium that could be conveyed > across databases, either by text files or by saving them off in a side table > prior to upgrade. JSONB met the criteria. Uh, it wouldn't be crazy to add this capability to pg_upgrade/pg_dump in a minor version upgrade if it wasn't enabled by default, and if we were very careful. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.