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 1sgXTn-003gvh-87 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 22:37:31 +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 1sgXTl-004GTp-5X for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 22:37:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sgXTk-004GTh-SD for pgsql-hackers@lists.postgresql.org; Tue, 20 Aug 2024 22:37:29 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sgXTh-000gKx-JO for pgsql-hackers@postgresql.org; Tue, 20 Aug 2024 22:37:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1724193446; bh=wZRqu7GstFFyqoXBf+W23Hr0OpxCzJtaYIOTspBXXwg=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=zUkwbyH7O21Ad0mGR3AK+HJVF6w6MMpvSpkH65rtmOxwQCOwBJQKa+KByt+Uh8FAa cY3plCK/PTi9amYqokQeX3wz25PadGUK4Df7Bt7eplXoc0m4uxoG60OR84bNyODcot jY8srXX9OPWE3sZRQPH3dNQkWLXIAvxKqw7oN43E8hEgOTt1FhAihq2Q3wPo3oSTcU p1JAKHc2nDSL4QVB9aD1SKg2d8pzZmsd/dEYfLBPnB2bIsbBOm5042ugbkqhrzTeAO 8ijPwkp3Q7KiMS3o2+8pXAc7i8g8NB3bXg4lUibB6D75/4rEdBux1DceIQxZnZcW6c bempGH6w99cYQ== Received: from [172.20.10.4] (unknown [89.113.147.14]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.rybakina@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id C03C760144; Wed, 21 Aug 2024 01:37:25 +0300 (MSK) Content-Type: multipart/alternative; boundary="------------TW6cUOisIe7OMIna37HbcUh9" Message-ID: <78394e29-a900-4af4-b5ce-d6eb2d263fad@postgrespro.ru> Date: Wed, 21 Aug 2024 01:37:16 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Vacuum statistics To: jian he Cc: Ilia Evdokimov , Andrei Zubkov , Alena Rybakina , pgsql-hackers , a.lepikhov@postgrespro.ru References: <53c47c2d-72a5-44f2-900c-9973b2af1808@tantorlabs.com> <4a902cea-54fb-41b5-b208-b84731a5f577@postgrespro.ru> Content-Language: en-US From: Alena Rybakina In-Reply-To: X-KSMG-AntiPhishing: NotDetected, bases: 2024/08/20 21:41:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2024/08/20 21:31:00 #26390795 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------TW6cUOisIe7OMIna37HbcUh9 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit We check it there: "tabentry->vacuum_ext.type != type". Or were you talking about something else? On 19.08.2024 12:32, jian he wrote: > in pg_stats_vacuum > if (type == PGSTAT_EXTVAC_INDEX || type == PGSTAT_EXTVAC_HEAP) > { > Oid relid = PG_GETARG_OID(1); > > /* Load table statistics for specified database. */ > if (OidIsValid(relid)) > { > tabentry = fetch_dbstat_tabentry(dbid, relid); > if (tabentry == NULL || tabentry->vacuum_ext.type != type) > /* Table don't exists or isn't an heap relation. */ > PG_RETURN_NULL(); > > tuplestore_put_for_relation(relid, rsinfo, tabentry); > } > else > { > } > > > So for functions pg_stat_vacuum_indexes and pg_stat_vacuum_tables, > it seems you didn't check "relid" 's relkind, > you may need to use get_rel_relkind. -- Regards, Alena Rybakina Postgres Professional:http://www.postgrespro.com The Russian Postgres Company --------------TW6cUOisIe7OMIna37HbcUh9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

We check it there: "tabentry->vacuum_ext.type != type". Or were you talking about something else?

On 19.08.2024 12:32, jian he wrote:
in pg_stats_vacuum
    if (type == PGSTAT_EXTVAC_INDEX || type == PGSTAT_EXTVAC_HEAP)
    {
        Oid                    relid = PG_GETARG_OID(1);

        /* Load table statistics for specified database. */
        if (OidIsValid(relid))
        {
            tabentry = fetch_dbstat_tabentry(dbid, relid);
            if (tabentry == NULL || tabentry->vacuum_ext.type != type)
                /* Table don't exists or isn't an heap relation. */
                PG_RETURN_NULL();

            tuplestore_put_for_relation(relid, rsinfo, tabentry);
        }
        else
        {
       }


So for functions pg_stat_vacuum_indexes and pg_stat_vacuum_tables,
it seems you didn't check "relid" 's relkind,
you may need to use get_rel_relkind.
-- 
Regards,
Alena Rybakina
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
--------------TW6cUOisIe7OMIna37HbcUh9--