Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gopuc-0001F1-39 for pgsql-admin@arkaria.postgresql.org; Wed, 30 Jan 2019 13:28:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1goptc-0005y3-RH for pgsql-admin@arkaria.postgresql.org; Wed, 30 Jan 2019 13:27:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goptc-0005xr-GH; Wed, 30 Jan 2019 13:27:16 +0000 Received: from smtp3-g21.free.fr ([212.27.42.3]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goptY-0000UI-Ki; Wed, 30 Jan 2019 13:27:15 +0000 Received: from firost (unknown [109.9.177.216]) (Authenticated sender: ioguix) by smtp3-g21.free.fr (Postfix) with ESMTPSA id 30B1B13F8D4; Wed, 30 Jan 2019 14:27:03 +0100 (CET) Date: Wed, 30 Jan 2019 14:27:01 +0100 From: "Jehan-Guillaume (ioguix) de Rorthais" To: Tumasgiu Rossini Cc: Mariel Cherkassky , pgsql-admin@lists.postgresql.org, pgsql-performance@lists.postgresql.org Subject: Re: pgstattupple vs pg_total_relation_size Message-ID: <20190130142701.38992d60@firost> In-Reply-To: References: X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 30 Jan 2019 14:19:52 +0100 Tumasgiu Rossini wrote: > According to the doc [1], > pg_total_relation_size add toasted data *and* indexes to the mix. *and* FSM *and* VM. > Any index, unique constraint, or primary key on your table ? >=20 > [1] > https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-AD= MIN-DBSIZE >=20 > Le mer. 30 janv. 2019 =C3=A0 11:42, Mariel Cherkassky < > mariel.cherkassky@gmail.com> a =C3=A9crit : =20 >=20 > > Hey, > > I'm using postgresql 9.6.11. I wanted to ask something about the functi= ons > > I mentioned in the title : > > I created the next table : > > postgres=3D# \d students; > > Table "public. students " > > Column | Type | Modifiers > > ----------+---------+----------- > > id| integer | > > name| text | > > age| integer | > > data | jsonb | > > > > I inserted one row. When I query the table`s size with > > pg_total_relation_size I see that the data occupies 2 pages : > > > > postgres=3D# select pg_total_relation_size(' students '); > > pg_total_relation_size > > ------------------------ > > 16384 > > (1 row) > > > > postgres=3D# select pg_relation_size(' students '); > > pg_relation_size > > ------------------ > > 8192 > > (1 row) > > > > When I used pgstattuple : > > postgres=3D# select * from pgstattuple('pg_toast.pg_toast_1187222'); > > table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count= | > > dead_tuple_len | dead_tuple_percent | free_space | free_percent > > > > -----------+-------------+-----------+---------------+-----------------= -+----------------+--------------------+------------+-------------- > > 0 | 0 | 0 | 0 | 0= | > > 0 | 0 | 0 | 0 > > (1 row) > > > > postgres=3D# select * from pgstattuple('students'); > > table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count= | > > dead_tuple_len | dead_tuple_percent | free_space | free_percent > > > > -----------+-------------+-----------+---------------+-----------------= -+----------------+--------------------+------------+-------------- > > 8192 | 1 | 1221 | 14.9 | 0= | > > 0 | 0 | 6936 | 84.67 > > (1 row) > > > > Which means, the toasted table is empty and you can see that the row I > > inserted should occupy only one page(8K in my system). > > > > Then, why the pg_total_relation_size shows another page ?(16KB in total) > > > > > > > > > > =20 --=20 Jehan-Guillaume de Rorthais Dalibo