From: | Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com> |
---|---|
To: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | pg_class.relpages not updated for toast index |
Date: | 2023-11-21 14:34:08 |
Message-ID: | CAFcNs+oLVK7LPYAweH=MXb9cKQKgoO9LkornjjeHnA=2SwfeoA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
Was doing a relation size estimation based on pg_class.relpages of the
relation and the related objects (index, toast) and noticed that it is not
updated for the toast index, for example:
fabrizio=# CREATE TABLE t(c TEXT);
INSERT INTO t VALUES (repeat('x', (8192^2)::int));
VACUUM (ANALYZE) t;
CREATE TABLE
INSERT 0 1
VACUUM
fabrizio=# \x on
Expanded display is on.
fabrizio=# SELECT
c.oid,
c.relname,
c.relpages,
t.relname,
t.relpages AS toast_pages,
ci.relname,
ci.relpages AS toast_index_pages,
(pg_stat_file(pg_relation_filepath(ci.oid))).size AS toast_index_size
FROM
pg_class c
JOIN pg_class t ON t.oid = c.reltoastrelid
JOIN pg_index i ON i.indrelid = t.oid
JOIN pg_class ci ON ci.oid = i.indexrelid
WHERE
c.oid = 't'::regclass;
-[ RECORD 1 ]-----+---------------------
oid | 17787
relname | t
relpages | 1
relname | pg_toast_17787
toast_pages | 97
relname | pg_toast_17787_index
toast_index_pages | 1
toast_index_size | 16384
Are there any reasons for toast index relpages not to be updated? Or is it
a bug?
Regards,
--
Fabrízio de Royes Mello
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-11-21 14:43:16 | Re: PSQL error: total cell count of XXX exceeded |
Previous Message | Alvaro Herrera | 2023-11-21 14:33:03 | Re: PSQL error: total cell count of XXX exceeded |