agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: Ben Peachey Higdon <bpeacheyhigdon@gmail.com>
To: pgsql-docs@lists.postgresql.org
Subject: Document if width_bucket's low and high are inclusive/exclusive
Date: Thu, 27 Feb 2025 20:31:59 -0500
Message-ID: <2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com> (raw)

The current documentation for width_bucket (https://www.postgresql.org/docs/current/functions-math.html <https://www.postgresql.org/docs/current/functions-math.html;) does not mention if the range’s low and high are inclusive or exclusive.

> Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high. Returns 0 or count+1 for an input outside that range.


I had assumed that both the low and high were inclusive but actually the low is inclusive while the high is exclusive.

For example:
SELECT width_bucket(0, 0, 1, 4)

returns 1, the first of 4 bins

SELECT width_bucket(1, 0, 1, 4) 

returns 5, because the high was outside the exclusive bound of high = 1

Thank you!=

view thread (10+ messages)  latest in thread

Message-ID: <2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com>
Permalink:  ../2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com/
Also on:    postgresql.org/message-id/2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bpeacheyhigdon@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: Document if width_bucket's low and high are inclusive/exclusive
  In-Reply-To: <2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox