Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSiQX-0003Oi-9A for pgsql-general@arkaria.postgresql.org; Wed, 14 Oct 2020 15:10:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kSiQV-0003oh-Sg for pgsql-general@arkaria.postgresql.org; Wed, 14 Oct 2020 15:10:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSiQV-0003oa-Lk for pgsql-general@lists.postgresql.org; Wed, 14 Oct 2020 15:10:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSiQP-0000km-C2 for pgsql-general@lists.postgresql.org; Wed, 14 Oct 2020 15:10:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09EFAdm33601487; Wed, 14 Oct 2020 11:10:39 -0400 From: Tom Lane To: Magnus Hagander cc: Thomas Kellerer , pgsql-general Subject: Re: Parameter value from (mb/gb) to bytes In-reply-to: References: <6cbca2bcda734464a1be9f7d7380ff33@rik.ee> Comments: In-reply-to Magnus Hagander message dated "Wed, 14 Oct 2020 17:01:33 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3601485.1602688239.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 14 Oct 2020 11:10:39 -0400 Message-ID: <3601486.1602688239@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 =3D '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=3D# select pg_size_bytes(setting||' '||unit) from pg_settings w= here name =3D '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. regards, tom lane