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 1m6zYc-0006QG-E9 for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Jul 2021 18:05:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6zYb-0000aA-30 for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Jul 2021 18:05:57 +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 1m6zYa-0000a1-ME for pgsql-hackers@lists.postgresql.org; Fri, 23 Jul 2021 18:05:56 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6zYY-0004r7-DV for pgsql-hackers@lists.postgresql.org; Fri, 23 Jul 2021 18:05:56 +0000 Received: from Egors-MacBook-Pro.local (unknown [45.137.112.250]) (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 1F4D521CD2C8; Fri, 23 Jul 2021 21:05:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1627063552; bh=debUaNXp37YpPfAH2JuU/GZz6ATen+R2FJbsB4uHDUY=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=B6PKeLcd9DomPHOUNfGewaVXcqxu+U31HChTEYd1cnSKODF0kaOXmwC+UVyOZM//6 quVzcC4DAYm42PbkFDf2UYAidHdDHrk2RcmuC8edSnuFchwQxBrnGw3gJRMC5fzeSJ b/yNo+WwmlLnqNvSKHaOJsyQeuXp5cuwNGSXfqjk= Subject: Re: pg_stats and range statistics To: Tomas Vondra , Soumyadeep Chakraborty Cc: PostgreSQL Hackers References: <55c8ecd4-57d0-5c63-6fe3-1b81e8caea9d@enterprisedb.com> From: Egor Rogov Message-ID: Date: Fri, 23 Jul 2021 21:05:50 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Tomas, On 12.07.2021 16:04, Tomas Vondra wrote: > On 7/12/21 1:10 PM, Egor Rogov wrote: >> Hi, >> >> thanks for the review and corrections. >> >> On 11.07.2021 21:54, Soumyadeep Chakraborty wrote: >>> Hello, >>> >>> This should have been added with [1]. >>> >>> Excerpt from the documentation: >>> "pg_stats is also designed to present the information in a more readable >>> format than the underlying catalog — at the cost that its schema must >>> be extended whenever new slot types are defined for pg_statistic." [2] >>> >>> So, I added a reminder in pg_statistic.h. >> Good point. >> >> >>> Attached is v2 of this patch with some cosmetic changes. >> I wonder why "TODO: catalog version bump"? This patch doesn't change >> catalog structure, or I miss something? >> > It changes system_views.sql, which is catalog change, as it redefines > the pg_stats system view (it adds 3 more columns). So it changes what > you get after initdb, hence catversion has to be bumped. > >>> Renamed the columns a >>> bit and updated the docs to be a bit more descriptive. >>> (range_length_empty_frac -> empty_range_frac, range_bounds_histogram -> >>> range_bounds_histograms) >> I intended to make the same prefix ("range_") for all columns concerned >> with range types, although I'm fine with the proposed naming. >> > Yeah, I'd vote to change empty_range_frac -> range_empty_frac. > >>> One question: >>> >>> We do have the option of representing the histogram of lower bounds >>> separately >>> from the histogram of upper bounds, as two separate view columns. >>> Don't know if >>> there is much utility though and there is a fair bit of added >>> complexity: see >>> below. Thoughts? >> I thought about it too, and decided not to transform the underlying data >> structure. As far as I can see, pg_stats never employed such >> transformations. For example, STATISTIC_KIND_DECHIST is an array >> containing the histogram followed by the average in its last element. It >> is shown in pg_stats.elem_count_histogram as is, although it arguably >> may be splitted into two fields. All in all, I believe pg_stats's job is >> to "unpack" stavalues and stanumbers into meaningful fields, and not to >> try to go deeper than that. >> > Not firm opinion, but the pg_stats is meant to be easier to > read/understand for humans. So far the transformation were simple > because all the data was fairly simple, but the range stuff may need > more complex transformation. > > For example we do quite a bit more in pg_stats_ext views, because it > deals with multi-column stats. In pg_stats_ext, yes, but not in pg_stats (at least until now). Since no one has expressed a strong desire for a more complex transformation, should we proceed with the proposed approach (with further renaming empty_range_frac -> range_empty_frac as you suggested)? Or should we wait more for someone to weigh in? > > > regards >