Re: Simplifying width_bucket_numeric()

Dean Rasheed <dean.a.rasheed@gmail.com>

From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Joel Jacobson <joel@compiler.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-07-10T19:31:02Z
Lists: pgsql-hackers
On Sun, 7 Jul 2024 at 13:43, Joel Jacobson <joel@compiler.org> wrote:
>
> > SELECT hash_array(array_agg(width_bucket(op, b1, b2, c))) FROM t;
> > -- Result not changed by patch
>
> Same hash_array on all my three machines:
>
> > SELECT sum(width_bucket(op, b1, b2, c)) FROM t;
> > Time: 3658.962 ms (00:03.659)  -- HEAD
> > Time: 3089.946 ms (00:03.090)  -- with patch
>
> Significant improvement on all my three machines:
>

Thanks for testing. I have committed this now.

(I also realised that the "reversed_bounds" code was unnecessary,
since the only effect was to negate both inputs to div_var(), so the
signs cancel out.)

Regards,
Dean



Commits

  1. Improve the numeric width_bucket() computation.