public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tatsuo Ishii <[email protected]>
To: [email protected]
Cc: [email protected]
Cc: [email protected]
Subject: Re: Issue with pgstattuple on Sequences in PostgreSQL
Date: Tue, 25 Jun 2024 09:37:50 +0900 (JST)
Message-ID: <20240625.093750.1243120916203808312.t-ishii@sranhm.sra.co.jp.sranhm> (raw)
In-Reply-To: <CAKFQuwbWg51wrQCNYe8J6V_KXoK5wQR3SERWKhCFwx6jx2OuOw@mail.gmail.com.sranhm>
References: <CACX+KaMOd3HHteOJNX7fkWxO+R=uLJkfKqE2-QUK8fKmKfOwqw@mail.gmail.com>
<CAKFQuwbWg51wrQCNYe8J6V_KXoK5wQR3SERWKhCFwx6jx2OuOw@mail.gmail.com.sranhm>
> On Monday, June 24, 2024, Ayush Vatsa <[email protected]> wrote:
>>
>> I was recently exploring the pgstattuple code directory and found this
>> piece of code: https://github.com/postgres/postgres/blob/master/contrib/
>> pgstattuple/pgstattuple.c#L255-L259.
>>
>> It indicates that pgstattuple supports relations, toast tables,
>> materialized views, and sequences.
>> However, when I executed a query with a sequence, I encountered the
>> following error:
>>
>> postgres=> CREATE SEQUENCE serial START 101;
>> CREATE SEQUENCE
>> postgres=> SELECT * FROM pgstattuple('serial');
>> ERROR: only heap AM is supported
>> postgres=>
>>
>> It got stuck in this if condition - https://github.com/postgres/
>> postgres/blob/master/contrib/pgstattuple/pgstattuple.c#L326-L329
>>
>>
>> How can one use pgstattuple on sequences?
>>
>
> As-is? Doesn’t look like you can.
It used to work until v11.
test=# SELECT * FROM pgstattuple('serial');
-[ RECORD 1 ]------+------
table_len | 8192
tuple_count | 1
tuple_len | 41
tuple_percent | 0.5
dead_tuple_count | 0
dead_tuple_len | 0
dead_tuple_percent | 0
free_space | 8104
free_percent | 98.93
It stopped working by this commit:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=4b82664156c230b59607704506f5b0a32ef49...
because pgstat_heap() rejects other than heap AM. I think the v12
release note should have explicitly mentioned that sequences are not
supported by pgstattuple any more.
> I agree it’s a documentation bug that
> this is the case with a brief explanation of why - sequences do not produce
> dead tuples and do not behave like real tables aside from being able to be
> selected from (i.e., no SQL update/delete command).
>
> The code should produce an explicit error for that relkind as well.
If so, then the regression test should be fixed as well. Currently
there's no test case for sequences.
Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
view thread (6+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Issue with pgstattuple on Sequences in PostgreSQL
In-Reply-To: <20240625.093750.1243120916203808312.t-ishii@sranhm.sra.co.jp.sranhm>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox