Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsEhJ-0000UQ-5B for pgsql-general@arkaria.postgresql.org; Mon, 29 Jul 2019 23:04:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsEhH-0004cJ-8f for pgsql-general@arkaria.postgresql.org; Mon, 29 Jul 2019 23:04:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsEhF-0004cC-Ly for pgsql-general@lists.postgresql.org; Mon, 29 Jul 2019 23:04:51 +0000 Received: from [66.111.4.27] (helo=out3-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsEhB-0005YH-Fb for pgsql-general@lists.postgresql.org; Mon, 29 Jul 2019 23:04:49 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id F1B1A220CB; Mon, 29 Jul 2019 19:04:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 29 Jul 2019 19:04:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=H JrduMKiU8V+/GIrYISFNcHGKA7O3Ok4QWeYRTT8SIw=; b=FEPxmno6GfTtRCG+v 8qO9+98UOLXHafnS7wW1Yrj/lu9Ct0bXumbjx3vl5xF003VxZNmug/12hxQGe3Gz HhKygG4e69KW9QmneF0ochjBfu+PdJJnxsGtSJavyye2wKeqCQeCq3pwiAUvFQVQ jV0J2XqbEDg7OANuqJKid4K8pCN3CYBwHFlm+aQ9THMPCYkwxGPfv1hj2/pP0za3 Mz3mlsVmAREgoINh6bev5byZyFWgVm73gcx4brX529pmY6BPo+qjGLXiRcf8ngHP Yb6vfT/WIyY2oLrxDKLQWixBVMZMVFqbpzJV3I8r0YP0iKOb7cRdBwrSQv6Z7P08 tcHOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=HJrduMKiU8V+/GIrYISFNcHGKA7O3Ok4QWeYRTT8S Iw=; b=nR5WZHp4KY+2qc3kLL0eyL3mkw29oYthnx6om44UknjEK3rzxWbYAbpgc 1TXctzkxPHFiaZv00nrtl3dz/3E0JLzmEEM0GHEm+179R0ncoVJw63ZnHaHvKfQ/ +IC8Vev6w8BOaoStRL6BSxKFn3b5FyeDzqGUtpDW/U5az2SV0MBsxa/rN6EeEgTW e5JMjgow1DmY1zJJDZcNsafjLjHgO+qmOJ5lbqlwWQ3n72Ch+vWriT2luZnNGPLz hHKYP619eQTL7D70Nq1Av2SM2yKEao4BQGJldk5qzTS63PujnSgAZxy818okCYVn HYa80K55nTvuqE/IqmwH8/K7NYKdw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrledvgddujecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecukfhppeehtddrudeljedrkedtrddvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegr ughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrhfuih iivgeptd X-ME-Proxy: Received: from ranger.suse (50-197-80-2-static.hfc.comcastbusiness.net [50.197.80.2]) by mail.messagingengine.com (Postfix) with ESMTPA id 22AD9380075; Mon, 29 Jul 2019 19:04:23 -0400 (EDT) Subject: Re: Reproducing query plans in empty database: can I just copy stats and settings? To: Tom Lane , Guyren Howe Cc: "pgsql-general@lists.postgresql.org" References: <7e758c6c-6e6f-d6b4-6ce5-55ac2bb95586@aklaver.com> <70D44AFB-74C8-4643-81C2-0A0143C68C47@gmail.com> <21596.1564438086@sss.pgh.pa.us> From: Adrian Klaver Message-ID: Date: Mon, 29 Jul 2019 16:04:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <21596.1564438086@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.27 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/29/19 3:08 PM, Tom Lane wrote: > Guyren Howe writes: >> On Jul 29, 2019, at 12:25 , Adrian Klaver wrote: >>> If you can't see/use the data in the production database in your test database I'm not sure how copying the statistics/cost settings is going to help. > >> Isn’t that the entirety of what the query plan is based on? > > No; physical sizes of the tables and indexes also matter. (The planner > scales some cost values by those numbers to account for the likelihood > that tables have grown since they were last analyzed.) You could deal > with that by bloating them with dummy data, of course. > > I think though that Adrian's point is a bit different: if you're not > allowed to see the original data, you should not be allowed to see > the statistics either. The histogram values and most-common-values > lists represent a pretty sizable information leak for such cases. Yeah that and access to the actual data. Not sure how you could run a query that replicated the production(even with cloned stats) if the table(s) are missing data. I could see throwing in dummy data, but it would need to correlate with the actual data and you don't know what that is. Then there is, what happens if you manually or autovacuum/analyze the test data? > > regards, tom lane > -- Adrian Klaver adrian.klaver@aklaver.com