Re: Simplifying width_bucket_numeric()

2024-07-10 Thread Dean Rasheed
On Sun, 7 Jul 2024 at 13:43, Joel Jacobson 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) -- HEA

Re: Simplifying width_bucket_numeric()

2024-07-07 Thread Bryan Green
🔥 On Sun, Jul 7, 2024, 7:44 AM Joel Jacobson wrote: > On Sat, Jul 6, 2024, at 17:36, Dean Rasheed wrote: > > In the numeric width_bucket() code, we currently do the following: > .. > > Instead, this can be done more simply and efficiently, using division > > with truncation as follows: > .. > >

Re: Simplifying width_bucket_numeric()

2024-07-07 Thread Joel Jacobson
On Sat, Jul 6, 2024, at 17:36, Dean Rasheed wrote: > In the numeric width_bucket() code, we currently do the following: .. > Instead, this can be done more simply and efficiently, using division > with truncation as follows: .. > > Patch attached. I didn't bother with any new test cases, since ther

Simplifying width_bucket_numeric()

2024-07-06 Thread Dean Rasheed
In the numeric width_bucket() code, we currently do the following: mul_var(&operand_var, count_var, &operand_var, operand_var.dscale + count_var->dscale); div_var(&operand_var, &bound2_var, result_var, select_div_scale(&operand_var, &bound2_var), true); if (cmp