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 1siFle-001DKy-II for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Aug 2024 16:07:03 +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 1siFlb-00GdRm-D3 for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Aug 2024 16:06:59 +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 1siFla-00GdRZ-PD for pgsql-hackers@lists.postgresql.org; Sun, 25 Aug 2024 16:06:59 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siFlX-001Nr0-EU for pgsql-hackers@postgresql.org; Sun, 25 Aug 2024 16:06:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1724602012; bh=5IAN/Vv97NrIdKsXn4xzww5aOFdnYEUkWp7jgjBD710=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=4nuR33FM/hqpVy8IVVoI7JrW+AC4w22km5nq2Ee0kUzCxtahNdP9d1Igb4EbZptpL cezxeRq99UKh47KcQo5/j5OYaGbjrCQDnKy86incevDeKYUSBqzdQrAM2XJS2N2Ixd 1hezmt1FLraq+nqKn5j+gDEd8WwGF1SgAjqORemsc1WnYtdwyIZmOxJ52ZWzd6qQRf do5HDhX9KGGCwIlsAV2i2YlzcFk40gVixsqo9CmlpD9OOp+3+mYj75eLiGTovI00U1 9H9DOFgrBz/8CpcxwPPTo3Ke8DMAZJnLuqL00bJFsCaqixwlJLEVUOUBAkYF7i8Jin fmWxmaf5CBUnw== Received: from [192.168.15.77] (unknown [45.137.112.9]) (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 493E96015D; Sun, 25 Aug 2024 19:06:52 +0300 (MSK) Content-Type: multipart/alternative; boundary="------------GpxL0SmCyWSV9zDhNrQurAqX" Message-ID: Date: Sun, 25 Aug 2024 19:06:51 +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> <78394e29-a900-4af4-b5ce-d6eb2d263fad@postgrespro.ru> Content-Language: en-US From: Alena Rybakina In-Reply-To: X-KSMG-AntiPhishing: NotDetected, bases: 2024/08/25 15:22: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/25 14:21:00 #26453186 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. --------------GpxL0SmCyWSV9zDhNrQurAqX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 22.08.2024 05:47, jian he wrote: > On Wed, Aug 21, 2024 at 6:37 AM Alena Rybakina > wrote: >> 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. >> >> -- > hi. > I mentioned some points at [1], > Please check the attached patchset to address these issues. Thank you for your work! I checked the patches and added your suggested changes to the new version of the patch here [0]. In my opinion, nothing was missing, but please take a look. [0] https://www.postgresql.org/message-id/c4e4e305-7119-4183-b49a-d7092f4efba3%40postgrespro.ru > > there are four occurrences of "CurrentDatabaseId", i am still confused > with usage of CurrentDatabaseId. It needed to be used because of scanning objects from the other database, so we change the id of dbid temporary to achieve it. You should snow that every part of this code was deleted.Now we can check information about tables and indexes from the current database. > also please don't top-post, otherwise the archive, like [2] is not > easier to read for future readers. > generally you quote first, then reply. > > [1]https://postgr.es/m/CACJufxHb_YGCp=pVH6DZcpk9yML+SueffPeaRbX2LzXZVahd_w@mail.gmail.com > [2]https://postgr.es/m/78394e29-a900-4af4-b5ce-d6eb2d263fad@postgrespro.ru Ok, no problem. -- Regards, Alena Rybakina Postgres Professional:http://www.postgrespro.com The Russian Postgres Company --------------GpxL0SmCyWSV9zDhNrQurAqX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 22.08.2024 05:47, jian he wrote:
On Wed, Aug 21, 2024 at 6:37 AM Alena Rybakina
<a.rybakina@postgrespro.ru> wrote:
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.

--
hi.
I mentioned some points at [1],
Please check the attached patchset to address these issues.

Thank you for your work! I checked the patches and added your suggested changes to the new version of the patch here [0]. In my opinion, nothing was missing, but please take a look.

[0] https://www.postgresql.org/message-id/c4e4e305-7119-4183-b49a-d7092f4efba3%40postgrespro.ru


there are four occurrences of "CurrentDatabaseId", i am still confused
with usage of CurrentDatabaseId.

It needed to be used because of scanning objects from the other database, so we change the id of dbid temporary to achieve it.

You should snow that every part of this code was deleted. Now we can check information about tables and indexes from the current database.

also please don't  top-post, otherwise the archive, like [2] is not
easier to read for future readers.
generally you quote first, then reply.

[1] https://postgr.es/m/CACJufxHb_YGCp=pVH6DZcpk9yML+SueffPeaRbX2LzXZVahd_w@mail.gmail.com
[2] https://postgr.es/m/78394e29-a900-4af4-b5ce-d6eb2d263fad@postgrespro.ru
Ok, no problem.
-- 
Regards,
Alena Rybakina
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
--------------GpxL0SmCyWSV9zDhNrQurAqX--