From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Erik Wienhold <ewie@ewie.name>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Exponentiation confusion
Date: Thu, 13 Oct 2022 20:07:08 +0100
Message-ID: <CAEZATCXEJGLE5h93f2LuaRYomF50SGa2vtQBHRZrZXtEjdft1Q@mail.gmail.com> (raw)
In-Reply-To: <979360.1665681418@sss.pgh.pa.us>
References: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com>
<603008316.190107.1665680007674@office.mailbox.org>
<979360.1665681418@sss.pgh.pa.us>
On Thu, 13 Oct 2022 at 18:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> I'm inclined to think that we should push the responsibility for choosing
> its rscale into power_var_int(), because internally that already does
> estimate the result weight, so with a little code re-ordering we won't
> need duplicative estimates. Don't have time to work on that right now
> though ... Dean, are you interested in fixing this?
>
OK, I'll take a look.
The most obvious thing to do is to try to make power_var_int() choose
the same result rscale as power_var() so that the results are
consistent regardless of whether the exponent is an integer.
It's worth noting, however, that that will cause in a *reduction* in
the output rscale rather than an increase in some cases, since the
power_var_int() code path currently always chooses an rscale of at
least 16, whereas the other code path in power_var() uses the rscales
of the 2 inputs, and produces a minimum of 16 significant digits,
rather than 16 digits after the decimal point. For example:
select power(5.678, 18.00000001::numeric);
power
-------------------------
37628507689498.14987457
(1 row)
select power(5.678, 18::numeric);
power
---------------------------------
37628507036041.8454541428979479
(1 row)
Regards,
Dean
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: dean.a.rasheed@gmail.com, tgl@sss.pgh.pa.us, ewie@ewie.name, adrian.klaver@aklaver.com
Subject: Re: Exponentiation confusion
In-Reply-To: <CAEZATCXEJGLE5h93f2LuaRYomF50SGa2vtQBHRZrZXtEjdft1Q@mail.gmail.com>
References: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com> <603008316.190107.1665680007674@office.mailbox.org> <979360.1665681418@sss.pgh.pa.us> <CAEZATCXEJGLE5h93f2LuaRYomF50SGa2vtQBHRZrZXtEjdft1Q@mail.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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox