Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sLjrY-00GJ3H-Nv for pgsql-general@arkaria.postgresql.org; Mon, 24 Jun 2024 13:36:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sLjrX-009bfn-10 for pgsql-general@arkaria.postgresql.org; Mon, 24 Jun 2024 13:36:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sLjrW-009bff-Ln for pgsql-general@lists.postgresql.org; Mon, 24 Jun 2024 13:36:02 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sLjrQ-002tUr-6Q for pgsql-general@lists.postgresql.org; Mon, 24 Jun 2024 13:36:01 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5c1ef5ac47eso707140eaf.2 for ; Mon, 24 Jun 2024 06:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719236155; x=1719840955; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VgQXoGS0kXbUfzMA5q0v18GihCBvNEBHja51p7FJNHs=; b=JYpnbmwUNeLjE00ia5R7Wm0CqqbTpG64PtUcl4ISRnuRDtgUFYcYJ4kurEMoH3L9Ja uAeI9jMIFnoZYE00gqVtdt62L0tdQSqlrP6aKjHXnTwKD869VaggoVEA0Pf7s+aI1RyM qNUDkPAmyiUx1EnxJelnodtmp9dIF1tlB4NdVBfYITLc+59J9gsffxHpfqaIeacKeFLh UoJ8ryEmwsQOUTxTSjwwLuzswN6FytwUTiKXAbPtUkYA8RF4YGy94Ui8kueIh641jORj mtHpHVHezZ0ijBoB1OqSdbkqvXAfJ9dF6LSQszsVc8Vlxl0rHJdKECNgwV5qokG7Pf64 KbeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719236155; x=1719840955; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VgQXoGS0kXbUfzMA5q0v18GihCBvNEBHja51p7FJNHs=; b=rE9LpdzsmupCMHPy7owC13t5Sf9ekM2ldPuX+xBBAXIGd19rvRTgpK5v/e1n5uZbyu DkH33LR+xEPUkvCVxGDymhFZprMnFi0p8znU/sV7Tjlbqr1N966PusnRdkTQJMbNJ0Ag LgqwlPnDLoBz6W3RdLMPGDMwMlXT+65QvkYbJK+6gXB51PiEm9zxiFDPgHlLu3OPxE8a VZGgDRUb9+g+VhcvR+6v3nt+KcSkHBztpsqYAYRvFqBo0aFE0V02du9zjhFMwsF5BN92 xdYqMPu7qh2TmBWubt8mvHx4wc0wniOXTFIMNv+NG0Q1rHPgrR7gY7kbTs92X8ZTuhS5 O3gA== X-Gm-Message-State: AOJu0YwfIXrvyQthLqVZrrR7QtBQUWUAlz51otnHFLt4v79ORdxxLOeD Pt8V3Z3oQh8CJobbpestDq0Jfm3M5uVjfHi98ihyFY2ScSHSAUOYvg+wxrKoHYvu5a6zlWzLWfT hscknCaIYct1x4dwhSZn/peQQFvc= X-Google-Smtp-Source: AGHT+IHMSHJiyYfa9zWmTQq22FwieetmIhX1LnpOcBnByq4nZYFGWSeLotazy4vbTDnyNpMIBta423kJeui3lu/vOhQ= X-Received: by 2002:a4a:8289:0:b0:5c1:b9ec:7258 with SMTP id 006d021491bc7-5c1e94bf665mr5147019eaf.0.1719236155045; Mon, 24 Jun 2024 06:35:55 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6802:1009:b0:539:aa10:6c7 with HTTP; Mon, 24 Jun 2024 06:35:54 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Mon, 24 Jun 2024 06:35:54 -0700 Message-ID: Subject: Re: Issue with pgstattuple on Sequences in PostgreSQL To: Ayush Vatsa Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000004e7f46061ba2dc27" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004e7f46061ba2dc27 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, June 24, 2024, Ayush Vatsa 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=3D> CREATE SEQUENCE serial START 101; > CREATE SEQUENCE > postgres=3D> SELECT * FROM pgstattuple('serial'); > ERROR: only heap AM is supported > postgres=3D> > > 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=E2=80=99t look like you can. I agree it=E2=80=99s a document= ation 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. David J. --0000000000004e7f46061ba2dc27 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, June 24, 2024, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

I was recently exploring the pgstattuple code dir= ectory and found this piece of code: https://github.com/postgres/postgres/blob= /master/contrib/pgstattuple/pgstattuple.c#L255-L259.=C2=A0

It indicates that pgstattuple supports relations, toast tables, materia= lized views, and sequences.
However, when I executed a query with a sequ= ence, I encountered the following error:

postgres=3D> CREATE SEQUE= NCE serial START 101;
CREATE SEQUENCE
postgres=3D> SELECT * FROM p= gstattuple('serial');
ERROR: =C2=A0only heap AM is supported
= postgres=3D>

It got stuck in this if condition - https://github.com/postgres/postgres/bl= ob/master/contrib/pgstattuple/pgstattuple.c#L326-L329

<= br>How can one use pgstattuple on sequences?=C2=A0


As-is?=C2=A0 Doesn=E2=80=99t look like you can.=C2=A0 I a= gree it=E2=80=99s a documentation bug that this is the case with a brief ex= planation of why - sequences do not produce dead tuples and do not behave l= ike real tables aside from being able to be selected from (i.e., no SQL upd= ate/delete command).

The code should produce an ex= plicit error for that relkind as well.

David J.

--0000000000004e7f46061ba2dc27--