Subject: Re: Optimize numeric multiplication for one and two base-NBASE digit multiplicands.

From: Robert Haas <[email-masked]>
Date: Wed, 3 Jul 2024 08:22:35 -0400

On Mon, Jul 1, 2024 at 6:19 PM Dean Rasheed <[email-masked]> wrote:
> Repeating your benchmark where both numbers have up to 2 NBASE-digits,
> this new approach was slightly faster:
>
> SELECT SUM(num1*num2) FROM bench_mul_var; -- HEAD
> Time: 4762.990 ms (00:04.763)
> Time: 4332.166 ms (00:04.332)
> Time: 4276.211 ms (00:04.276)
> Time: 4247.321 ms (00:04.247)
> Time: 4166.738 ms (00:04.167)
>
> SELECT SUM(num1*num2) FROM bench_mul_var; -- v2 patch
> Time: 4398.812 ms (00:04.399)
> Time: 3672.668 ms (00:03.673)
> Time: 3650.227 ms (00:03.650)
> Time: 3611.420 ms (00:03.611)
> Time: 3534.218 ms (00:03.534)
>
> SELECT SUM(num1*num2) FROM bench_mul_var; -- this patch
> Time: 3350.596 ms (00:03.351)
> Time: 3336.224 ms (00:03.336)
> Time: 3335.599 ms (00:03.336)
> Time: 3336.990 ms (00:03.337)
> Time: 3351.453 ms (00:03.351)

I don't have any particular technical insight on this topic, but I
just want to mention that I'm excited about the work. Numeric
performance can be painfully slow, and these seem like quite
significant speedups that will affect lots of real-world cases.

-- 
Robert Haas
EDB: http://www.enterprisedb.com