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 1kCghf-0005Yq-Hb for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Aug 2020 10:06:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kCghe-0001GE-Fn for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Aug 2020 10:06:18 +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 1kCghe-0001G4-5a for pgsql-hackers@lists.postgresql.org; Mon, 31 Aug 2020 10:06:18 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kCghb-0001xX-0r for pgsql-hackers@lists.postgresql.org; Mon, 31 Aug 2020 10:06:17 +0000 Received: from [192.168.129.197] (unknown [94.25.177.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id B6F5E21C1FD6; Mon, 31 Aug 2020 13:06:11 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1598868372; bh=PUZq1CsMN9qAeplakwsrcFOp+JNEPkfgkqatHXcDrNI=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=AanNU8XN4B9QyWmJymCIsV3+7acgtFvyyPYWkcqrbr1sHbT4abpstaoKFCkRqt3Gu i/skdvqDNnWyi+9cpZcb2AzwOJTfpfpWUOPPWsvOKg6CCeR9uB2+rJuEw25oDhSN/l SBMV2A+tFHRMy+L6iP7vK/5g1EKoEQFumsAFFBW4= Subject: Re: Ideas about a better API for postgres_fdw remote estimates To: Tom Lane , Stephen Frost Cc: Bruce Momjian , pgsql-hackers@lists.postgresql.org, Etsuro Fujita , Jeff Janes References: <1155731.1593832096@sss.pgh.pa.us> <20200705170601.GD3125@tamriel.snowman.net> <1301903.1593970603@sss.pgh.pa.us> <20200705174817.GE3125@tamriel.snowman.net> <1309399.1593980722@sss.pgh.pa.us> <20200706141114.GF3125@tamriel.snowman.net> <1374896.1594047946@sss.pgh.pa.us> <20200706152828.GG3125@tamriel.snowman.net> <20200714013219.GD32422@momjian.us> <7a40707d-1758-85a2-7bb1-6e5775518e64@postgrespro.ru> <20200829162231.GE29590@tamriel.snowman.net> <3565504.1598719859@sss.pgh.pa.us> From: "Andrey V. Lepikhov" Organization: Postgres Professional Message-ID: <0a75a7b9-d800-4c70-7eec-7fa7630a854b@postgrespro.ru> Date: Mon, 31 Aug 2020 15:06:09 +0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <3565504.1598719859@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/29/20 9:50 PM, Tom Lane wrote: > Years ago (when I was still at Salesforce, IIRC, so ~5 years) we had > some discussions about making it possible for pg_dump and/or pg_upgrade > to propagate stats data forward to the new database. There is at least > one POC patch in the archives for doing that by dumping the stats data > wrapped in a function call, where the target database's version of the > function would be responsible for adapting the data if necessary, or > maybe just discarding it if it couldn't adapt. We seem to have lost > interest but it still seems like something worth pursuing. I'd guess > that if such infrastructure existed it could be helpful for this. Thanks for this helpful feedback. I found several threads related to the problem [1-3]. I agreed that this task needs to implement an API for serialization/deserialization of statistics: pg_load_relation_statistics(json_string text); pg_get_relation_statistics(relname text); We can use a version number for resolving conflicts with different statistics implementations. "Load" function will validate the values[] anyarray while deserializing the input json string to the datatype of the relation column. Maybe I didn't feel all the problems of this task? 1. https://www.postgresql.org/message-id/flat/724322880.K8vzik8zPz%40abook 2. https://www.postgresql.org/message-id/flat/CAAZKuFaWdLkK8eozSAooZBets9y_mfo2HS6urPAKXEPbd-JLCA%40mail.gmail.com 3. https://www.postgresql.org/message-id/flat/GNELIHDDFBOCMGBFGEFOOEOPCBAA.chriskl%40familyhealth.com.au -- regards, Andrey Lepikhov Postgres Professional