Re: Parameter value from (mb/gb) to bytes

2020-11-19 Thread Raul Kaubi
Hi Thanks, you solution works for most of the databases. But now I noticed that we have single 9.5 version also. And seems like this function *pg_size_bytes* came from 9.6 # psql -U postgres -Atc "select > pg_size_bytes(current_setting('shared_buffers'));" > ERROR: function pg_size_bytes(text) d

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Magnus Hagander
On Wed, Oct 14, 2020 at 5:23 PM Tom Lane wrote: > Magnus Hagander writes: > > On Wed, Oct 14, 2020 at 5:10 PM Tom Lane wrote: > >> It's fairly annoying that this doesn't work: > >> regression=# select pg_size_bytes(setting||' '||unit) from pg_settings > >> where name = 'shared_buffers'; > > > A

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Raul Kaubi
Hi Thanks for all the replies. So at first, I did this: select (pg_size_bytes(setting) * (select setting from pg_settings where name = 'block_size')::int) as shared_buffers from pg_settings where name = 'shared_buffers'; But as I understood, that the preferred way would be this, correct..? (at

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Tom Lane
Magnus Hagander writes: > On Wed, Oct 14, 2020 at 5:10 PM Tom Lane wrote: >> It's fairly annoying that this doesn't work: >> regression=# select pg_size_bytes(setting||' '||unit) from pg_settings >> where name = 'shared_buffers'; > Actually thinking though, surely *this* particular case can be s

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Magnus Hagander
On Wed, Oct 14, 2020 at 5:10 PM Tom Lane wrote: > Magnus Hagander writes: > > On Wed, Oct 14, 2020 at 3:57 PM Thomas Kellerer 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 depend

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Christoph Moench-Tegeder
## Magnus Hagander (mag...@hagander.net): > 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 :) More self-contained: select pg_s

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Pavel Stehule
st 14. 10. 2020 v 17:10 odesílatel Tom Lane napsal: > Magnus Hagander writes: > > On Wed, Oct 14, 2020 at 3:57 PM Thomas Kellerer 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 de

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Tom Lane
Magnus Hagander writes: > On Wed, Oct 14, 2020 at 3:57 PM Thomas Kellerer 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 correc

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Magnus Hagander
On Wed, Oct 14, 2020 at 3:57 PM Thomas Kellerer wrote: > Thomas Kellerer schrieb am 14.10.2020 um 15:55: > > Raul Kaubi schrieb am 14.10.2020 um 12:22: > >> Is there a simple way to dynamically get for example parameter > >> „shared buffers“ value (megabytes or gigabytes) to bytes, for > >> monit

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Thomas Kellerer
Thomas Kellerer schrieb am 14.10.2020 um 15:55: > Raul Kaubi schrieb am 14.10.2020 um 12:22: >> Is there a simple way to dynamically get for example parameter >> „shared buffers“ value (megabytes or gigabytes) to bytes, for >> monitoring perspective..?> >>   >> >> At the moment, this gives me value

Re: Parameter value from (mb/gb) to bytes

2020-10-14 Thread Thomas Kellerer
Raul Kaubi schrieb am 14.10.2020 um 12:22: > Is there a simple way to dynamically get for example parameter > „shared buffers“ value (megabytes or gigabytes) to bytes, for > monitoring perspective..?> >   > > At the moment, this gives me value in GB. > > # psql -U postgres -Atc "show shared_buffers