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 1uSGvp-005XKU-Io for pgsql-docs@arkaria.postgresql.org; Thu, 19 Jun 2025 15:12:01 +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 1uSGvm-00CDZf-0L for pgsql-docs@arkaria.postgresql.org; Thu, 19 Jun 2025 15:11:58 +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 1uSGvl-00CDZX-Oz for pgsql-docs@lists.postgresql.org; Thu, 19 Jun 2025 15:11:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uSGvk-002uWW-1g for pgsql-docs@lists.postgresql.org; Thu, 19 Jun 2025 15:11:57 +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 55JFBrHb1391434; Thu, 19 Jun 2025 11:11:53 -0400 From: Tom Lane To: Robert Treat cc: Ben Peachey Higdon , pgsql-docs@lists.postgresql.org Subject: Re: Document if width_bucket's low and high are inclusive/exclusive In-reply-to: References: <2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com> <1167135.1750277532@sss.pgh.pa.us> Comments: In-reply-to Robert Treat message dated "Wed, 18 Jun 2025 21:51:39 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1391432.1750345913.1@sss.pgh.pa.us> Date: Thu, 19 Jun 2025 11:11:53 -0400 Message-ID: <1391433.1750345913@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Treat writes: > Since they are all lower bounds, they all operate the same way, so it > isn't quite as clear that it needs documenting. Are you thinking > something like this? > Returns the number of the bucket in which operand falls given an array > listing the lower bounds (inclusive) of the buckets Yeah, though I might write "inclusive lower bounds" rather than use parens. What's bugging me though is the lack of any mention of the bucket upper bounds: you have to deduce that the upper bounds must be exclusive if the lower bounds are inclusive. If that's obvious here, why is it non-obvious for the other case? Maybe instead of the parenthetical form you suggested, add a sentence like Buckets have inclusive lower bounds, and therefore exclusive upper bounds. and then we could either rely on the reader remembering that, or else repeat it, for the second form of width_bucket. Another thing I just remembered (think I knew it once) is the behavior of the first form when low > high. It's not an error! I think we need to document that, perhaps along the lines of If low > high, the behavior is mirror-reversed, with bucket 1 now being the one just below low, and the inclusive bounds now being on the upper side. plus an example. regards, tom lane