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 1tnzK6-004UiX-4P for pgsql-docs@arkaria.postgresql.org; Fri, 28 Feb 2025 12:18:35 +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 1tnzK7-004dJz-84 for pgsql-docs@arkaria.postgresql.org; Fri, 28 Feb 2025 12:18:33 +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 1tnpET-00APRD-TY for pgsql-docs@lists.postgresql.org; Fri, 28 Feb 2025 01:32:04 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tnpEQ-0004r6-2J for pgsql-docs@lists.postgresql.org; Fri, 28 Feb 2025 01:32:03 +0000 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-4721f53e6ecso16574511cf.1 for ; Thu, 27 Feb 2025 17:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740706322; x=1741311122; darn=lists.postgresql.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=8rCxThgUOBLFY2fs5FAGeE8xvps17WlbEJ3Xfd1mobw=; b=A2bXU8Lkb+KZeLm2Z49GJ+0oFiq80zQoSr4bfZUTVXUA0WGqy0MgPs7eamT3agnGUE CkKXrLk6z8t/qFk8ddyYxhynT5wQeeu6HZvTDufUlzHW70EIQUxsQRppb22XdZNpFkah PgEK9ziwxAdSlSvSv94kUVgI+7fKrdp7lCmtqdPntR6m5rht4pqSao0dOZtGGZO5m9FC WA7b1s/MUYpO3nNODo963KmnlG0TyhNxsiZ962EbXrw0T5SSA5xq88EgD7IyByhgyyxv SlCzi/hyEd/ti/Av+Eknga/S0vLh+bgXGyaxAxCQptaXg7Qe3mayPHRs7jvjzox+nyoj ccZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740706322; x=1741311122; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8rCxThgUOBLFY2fs5FAGeE8xvps17WlbEJ3Xfd1mobw=; b=YtfLPUyQbaJY/kbHPWStFnGIv4M/JducWGLLBKin72unze9Gr3XN+346cg+NKbtmbz QjnF9WyxBee4v4Ue4BYR0MRe/Hg0YY2c6HhtekVCLPZXuQOjNmgqgMFPx+0NCrzK5zdk 9xIu+5CDIaqwUXXs99Nppj2Axn3ejbZqJsH5OiCy3cwLXdVxl89475hfWK1L9lYWy/W/ q/rlgqfi69J33HcGPfNsiu1DAURW8Gp8wHjiebOwWNIpH/SfnGiQH/9UwjkmYkw1IClt h07Dgx0lav5NoD0r3vAGy2u+PJvGbUVWmaowc4pdvwZdJYYtEP+ld2Apcz1jZmwhpDOQ FNIQ== X-Gm-Message-State: AOJu0YwDfArTflJ8Aw3rhbKNnORaKK7a+QIzVBJiuYzTnhf2t/v+SlYx 8Ev2APkhfnhdHXCGEG+UybbpCzhmcF+tY0jpW9JFj193e6mx+jY/X8tYQw== X-Gm-Gg: ASbGncsch5K5mYcjcFThd3LHR+AnZiDjs6dq8azTV0FDKAyGaetAlKUJ6hDavZM1kDT Yu2bSY2cL3NlfHOUxGai8qSKacBkdkZiLAqSHIt/Jcj7pyfgb/Ae85B6AlALSOTFK9s3Pw0IOzX TP8CWIS13YLr1p9aIG8MIPOY9mw7m0YRuVkAK6eZyCn+hOxKeuisYhkiQFpjD8MROutiNHlpsRj ke3omnEZa6E4HzFkNX0ggsGpUgu/L/W9lE/+1Ia3OsHkKVptRinSF8VMlRGWVGRkSXcei9vstFX dBmlLai5gNhzugIbtZmCI0V1fmxisB6Ucb/Qf3eHbNcV86mxHLhHHoUawU8= X-Google-Smtp-Source: AGHT+IG1c3oq+N8dpoE3GPpgJ0+5w/+cpCc14bWg5h/nlTrFBHp+JtuFyOYoCjValTGko9tQpQkn1A== X-Received: by 2002:a05:622a:64e:b0:472:6ed:a7c5 with SMTP id d75a77b69052e-474bc081591mr19982431cf.14.1740706321923; Thu, 27 Feb 2025 17:32:01 -0800 (PST) Received: from smtpclient.apple ([2607:fea8:129d:bf00:15f1:5db:5c7a:ea00]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-474721bfb99sm18603081cf.44.2025.02.27.17.32.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Feb 2025 17:32:01 -0800 (PST) From: Ben Peachey Higdon Content-Type: multipart/alternative; boundary="Apple-Mail=_B372ABDA-7784-4311-B8B5-65B4ED359D1D" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.10\)) Subject: Document if width_bucket's low and high are inclusive/exclusive Message-Id: <2BD74F86-5B89-4AC1-8F13-23CED3546AC1@gmail.com> Date: Thu, 27 Feb 2025 20:31:59 -0500 To: pgsql-docs@lists.postgresql.org X-Mailer: Apple Mail (2.3696.120.41.1.10) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_B372ABDA-7784-4311-B8B5-65B4ED359D1D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 The current documentation for width_bucket = (https://www.postgresql.org/docs/current/functions-math.html = ) does not = mention if the range=E2=80=99s 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)=20 returns 5, because the high was outside the exclusive bound of high =3D = 1 Thank you!= --Apple-Mail=_B372ABDA-7784-4311-B8B5-65B4ED359D1D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 The = current documentation for width_bucket (https://www.postgresql.org/docs/current/functions-math.html= ) does not mention if the range=E2=80=99s 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 =3D 1

Thank you!
= --Apple-Mail=_B372ABDA-7784-4311-B8B5-65B4ED359D1D--