From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Thomas Kellerer <shammat(at)gmx(dot)net>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Parameter value from (mb/gb) to bytes |
Date: | 2020-10-14 15:16:57 |
Message-ID: | CABUevEz3Ya0eWPJPvU5ymHPbK1OTtaFUMbzV2u7ULS9d_ORtyg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Oct 14, 2020 at 5:10 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
> > On Wed, Oct 14, 2020 at 3:57 PM Thomas Kellerer <shammat(at)gmx(dot)net> wrote:
> >> select pg_size_bytes(setting) * 8192
> >> from pg_settings
> >> where name = 'shared_buffers';
>
> > Actually, it doesn't have to be in 8k pages, that depends on the build
> > options. So if you want to be perfectly correct, you should probably
> > multiply with current_setting('block_size') instead of a hardcoded 8192
> :)
>
> It's fairly annoying that this doesn't work:
>
> regression=# select pg_size_bytes(setting||' '||unit) from pg_settings
> where name = 'shared_buffers';
> ERROR: invalid size: "16384 8kB"
> DETAIL: Invalid size unit: "8kB".
> HINT: Valid units are "bytes", "kB", "MB", "GB", and "TB".
>
> Maybe we should teach pg_size_bytes to cope with that.
>
Actually thinking though, surely *this* particular case can be spelled as:
SELECT pg_size_bytes(current_setting('shared_buffers'))
Or if doing it off pg_settings:
SELECT setting::bigint * pg_size_bytes(unit) from pg_settings where
name='shared_buffers'
I'm not sure having pg_size_bytes() parse "16384 8kB" is reasonable, I have
a feeling that could lead to a lot of accidental entries giving the wrong
results.
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Moench-Tegeder | 2020-10-14 15:17:26 | Re: Parameter value from (mb/gb) to bytes |
Previous Message | Anthony DeBarros | 2020-10-14 15:16:37 | PostGIS missing from EDB Windows installer for PG13? |