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 1t7DBI-000fEi-T3 for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Nov 2024 12:24:41 +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 1t7DBG-005lQ7-VT for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Nov 2024 12:24:39 +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 1t7DBG-005lPz-F6 for pgsql-hackers@lists.postgresql.org; Sat, 02 Nov 2024 12:24:39 +0000 Received: from forward101a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d101]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t7DBD-004Ljn-P7 for pgsql-hackers@postgresql.org; Sat, 02 Nov 2024 12:24:38 +0000 Received: from mail-nwsmtp-smtp-production-main-31.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-31.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:26bf:0:640:efa0:0]) by forward101a.mail.yandex.net (Yandex) with ESMTPS id 216D8608FE; Sat, 2 Nov 2024 15:24:33 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-31.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id VOcjx7NuHGk0-P2L2PKCI; Sat, 02 Nov 2024 15:24:32 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1730550272; bh=ydIqrqhnbGSZd3GZbafQIKJ8QKOlHHZMgJE4NoIEa7A=; h=In-Reply-To:Cc:Date:References:To:Subject:Message-ID:From; b=PRlXHlFJ2FsNDkFYH7Uif0a1CNUK8lQASXWryE/4HpwX3Mrg3jBuRMg5QgfDgwuZs 8xEqa0S5SrD/k1AADKXqzzujwk4A+lywO7LkelKjkZtD6TqYZgXXpaYcxfPR4AvCY7 BfNEjWq26jvo2jlSWhTOBgdJ1FwJijJe8G2tLXwg= Authentication-Results: mail-nwsmtp-smtp-production-main-31.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Content-Type: multipart/alternative; boundary="------------XSs3iUuTnZPBQ1kQEtOw9dah" Message-ID: Date: Sat, 2 Nov 2024 15:24:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Vacuum statistics To: Alexander Korotkov Cc: Ilia Evdokimov , Andrei Zubkov , pgsql-hackers , a.lepikhov@postgrespro.ru, jian he References: <53c47c2d-72a5-44f2-900c-9973b2af1808@tantorlabs.com> <4a902cea-54fb-41b5-b208-b84731a5f577@postgrespro.ru> <092adec6-4eae-4bd4-bd0d-473a9df1282b@tantorlabs.com> <3deae1bd-ad84-4459-a26e-04c9136b84e9@postgrespro.ru> Content-Language: en-US From: Alena Rybakina In-Reply-To: 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. --------------XSs3iUuTnZPBQ1kQEtOw9dah Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi! On 29.10.2024 14:02, Alena Rybakina wrote: > On 28.10.2024 16:40, Alexander Korotkov wrote: >> On Sun, Aug 25, 2024 at 6:59 PM Alena Rybakina >> wrote: >>> I didn't understand correctly - did you mean that we don't need SRF if >>> we need to display statistics for a specific object? >>> >>> Otherwise, we need this when we display information on all database >>> objects (tables or indexes): >>> >>> while ((entry = ScanStatSnapshot(pgStatLocal.snapshot.stats, &hashiter)) >>> != NULL) >>> { >>> CHECK_FOR_INTERRUPTS(); >>> >>> tabentry = (PgStat_StatTabEntry *) entry->data; >>> >>> if (tabentry != NULL && tabentry->vacuum_ext.type == type) >>> tuplestore_put_for_relation(relid, rsinfo, tabentry); >>> } >>> >>> I know we can construct a HeapTuple object containing a TupleDesc, >>> values, and nulls for a particular object, but I'm not sure we can >>> augment it while looping through multiple objects. >>> >>> /* Initialise attributes information in the tuple descriptor */ >>> >>> tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_SUBSCRIPTION_STATS_COLS); >>> >>> ... >>> >>> PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls))); >>> >>> >>> If I missed something or misunderstood, can you explain in more detail? >> Actually, I mean why do we need a possibility to return statistics for >> all tables/indexes in one function call? User anyway is supposed to >> use pg_stat_vacuum_indexes/pg_stat_vacuum_tables view, which do >> function calls one per relation. I suppose we can get rid of >> possibility to get all the objects in one function call and just >> return a tuple from the functions like other pgstatfuncs.c functions >> do. >> > I haven’t thought about this before and agree with you. Thanks for the > clarification! I'll fix the patch this evening and release the updated > version. I updated the patches as per your suggestion. You can see it here [0]. [0] https://www.postgresql.org/message-id/85b963fe-5977-43aa-9241-75b862abcc69%40postgrespro.ru --------------XSs3iUuTnZPBQ1kQEtOw9dah Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi!

On 29.10.2024 14:02, Alena Rybakina wrote:
On 28.10.2024 16:40, Alexander Korotkov wrote:
On Sun, Aug 25, 2024 at 6:59 PM Alena Rybakina
<a.rybakina@postgrespro.ru> wrote:
I didn't understand correctly - did you mean that we don't need SRF if
we need to display statistics for a specific object?

Otherwise, we need this when we display information on all database
objects (tables or indexes):

while ((entry = ScanStatSnapshot(pgStatLocal.snapshot.stats, &hashiter))
!= NULL)
{
     CHECK_FOR_INTERRUPTS();

     tabentry = (PgStat_StatTabEntry *) entry->data;

     if (tabentry != NULL && tabentry->vacuum_ext.type == type)
         tuplestore_put_for_relation(relid, rsinfo, tabentry);
}

I know we can construct a HeapTuple object containing a TupleDesc,
values, and nulls for a particular object, but I'm not sure we can
augment it while looping through multiple objects.

/* Initialise attributes information in the tuple descriptor */

  tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_SUBSCRIPTION_STATS_COLS);

...

PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls)));


If I missed something or misunderstood, can you explain in more detail?
Actually, I mean why do we need a possibility to return statistics for
all tables/indexes in one function call?  User anyway is supposed to
use pg_stat_vacuum_indexes/pg_stat_vacuum_tables view, which do
function calls one per relation.  I suppose we can get rid of
possibility to get all the objects in one function call and just
return a tuple from the functions like other pgstatfuncs.c functions
do.

I haven’t thought about this before and agree with you. Thanks for the clarification! I'll fix the patch this evening and release the updated version.

    

I updated the patches as per your suggestion. You can see it here [0].

[0] https://www.postgresql.org/message-id/85b963fe-5977-43aa-9241-75b862abcc69%40postgrespro.ru

--------------XSs3iUuTnZPBQ1kQEtOw9dah--