Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcnQZ-0007VR-NQ for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Mar 2023 13:13:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pcnQY-0006JN-EV for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Mar 2023 13:13:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcnQY-0006JD-2W for pgsql-hackers@lists.postgresql.org; Thu, 16 Mar 2023 13:13:54 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pcnQT-0008CE-72 for pgsql-hackers@lists.postgresql.org; Thu, 16 Mar 2023 13:13:53 +0000 Received: by mail-wm1-x333.google.com with SMTP id m18-20020a05600c3b1200b003ed2a3d635eso1099088wms.4 for ; Thu, 16 Mar 2023 06:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678972427; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=pqPCjxjjUjGf60ePPs4MShMkU7gcFLlfUFQvOVMrSro=; b=BYM7h2dMRZQSZ0v1IxxVSLLOErjbmveGE8lhr51+hkjrI5IDGgvr9jsVA2nj7PrHtT xxthNRus3Kp3jIt8mQXMx7IXj8PVkDX6uJxVZqjSyAmvybUFAKKCJqZJiMZqSUxKWZoq ebteLNpjUZm3rBBtFIaiAgexYSJ81dF8pALWQ9DsDqyt3dpuHyI1T3pfRnbW1x6Dc9o9 LuaPaBw0MJfp40CrKHOmS3Ud4gT02UTDcg7QNBMjzvcasxRtDN7e6gTtNJOrf1XZpv6E TyDF3qJ16xidCjMQWycg21+LpIVtkTaLorN7GKMlcMHMDU+PVeB47iUJsQ4/vdhA9yAC /pjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678972427; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pqPCjxjjUjGf60ePPs4MShMkU7gcFLlfUFQvOVMrSro=; b=ouQGDfopMeOPLmP+puW20GhGaNbsom2mU2WEpbMxS6/nwB5j0+L4b9E8nyWCiLr1hc Q8va7ApPbxizWWvawGg49Ii92os4vv8wshe64K9bYbfh/HQUjUww4ntuXmxhyfscVadG X5C7lejfngkzF8HVNsANkaMAISOcmSOLDw4JCijlIm8ohSKGoX+xf0wsvuIKgci1MVVJ +xn6Vx/KPpfgSd0+TUNX2poP9RbtrURsve3A2b9RaWGQz+90JFQSYYYkY68zqyhGPp3E 9empi8jKpy/xtjaTLgCluPy4fKnVzR9FyJ2KrbxN49EFI9H5fLAGS+gMCanf7ncPOK44 6fVA== X-Gm-Message-State: AO0yUKXanovptU0tOWqj74ejMki1EhZ9DqPaPrQZ11zTIUeSVBmNpNy1 x3Qkge6L4MC1vlBMoLy/jj4= X-Google-Smtp-Source: AK7set+SdKh1fsdofR7kAoJqjkNuJ0myVJWLJj4heAGEPFihm4E6GMmYllRwRMijiZ9OnAMQVx6uqw== X-Received: by 2002:a05:600c:5398:b0:3eb:3945:d3f1 with SMTP id hg24-20020a05600c539800b003eb3945d3f1mr21991700wmb.5.1678972427559; Thu, 16 Mar 2023 06:13:47 -0700 (PDT) Received: from [192.168.22.74] ([54.239.6.186]) by smtp.gmail.com with ESMTPSA id 1-20020a05600c234100b003e00c453447sm4856790wmq.48.2023.03.16.06.13.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Mar 2023 06:13:46 -0700 (PDT) Message-ID: Date: Thu, 16 Mar 2023 14:13:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: Reconcile stats in find_tabstat_entry() and get rid of PgStat_BackendFunctionEntry Content-Language: en-US To: Michael Paquier Cc: Andres Freund , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org References: <20230214.151102.1070436528757437157.horikyota.ntt@gmail.com> <9262b2a9-6785-1f83-bf7f-7fcf90c2c113@gmail.com> <20230215.095644.822493184688844040.horikyota.ntt@gmail.com> <130095b4-7c6d-b6f1-69d4-94f66231f81d@gmail.com> <20230216212121.uvav7xgdh2ysqjy5@awork3.anarazel.de> <621ed53c-4d9a-8f77-ab8c-20235f2d95a1@gmail.com> From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/16/23 12:46 PM, Michael Paquier wrote: > On Thu, Mar 16, 2023 at 11:32:56AM +0100, Drouvot, Bertrand wrote: >> On 3/16/23 7:29 AM, Michael Paquier wrote: >>> From what I get with this change, the number of tuples changed by DMLs >>> have their computations done a bit earlier, >> >> Thanks for looking at it! >> >> Right, but note this is in a dedicated new tablestatus (created >> within find_tabstat_entry()). > > Sure, however it copies the pointer of the PgStat_TableXactStatus from > tabentry, isn't it? Oh I see what you mean, yeah, the pointer is copied. > This means that it keeps a reference of the chain > of subtransactions. It does not matter for the functions but it could > for out-of-core callers of find_tabstat_entry(), no? Yeah, maybe. > Perhaps you are > right and that's not worth worrying, still I don't feel particularly > confident that this is the best approach we can take. > due to what potential out-of-core callers could do with it? >>> How much do we need to care about the remaining two callers >>> pg_stat_get_xact_blocks_fetched() and pg_stat_get_xact_blocks_hit()? >> >> Regarding pg_stat_get_xact_blocks_fetched() and pg_stat_get_xact_blocks_hit() >> the callers (if any) are outside of the core PG (as from what I can >> see they are not used at all). >> >> I don't think we should pay any particular attention to those 2 ones >> as anyway nothing prevent the 7 others to be called outside of the >> pg_stat_xact_all_tables view. > > I am not quite sure, TBH. Did you look at the difference with a long > chain of subtrans, like savepoints? The ODBC driver "loves" producing > a lot of savepoints, for example. > No, I did not measure the impact. >>> It would feel a bit safer to me to document that find_tabstat_entry() >>> is currently only used for this xact system view.. The extra >>> computation could lead to surprises, actually, if this routine is used >>> outside this context? Perhaps that's OK, but it does not give me a >>> warm feeling, just to reshape three functions of pgstatfuncs.c with >>> macros. >> >> That's a fair point. On the other hand those 9 functions (which can >> all be used outside of the pg_stat_xact_all_tables view) are not >> documented, so I'm not sure this is that much of a concern (and if >> we think it is we still gave the option to add an extra flag to >> indicate whether or not the extra computation is needed.) > > That's not quite exact, I think. The first 7 functions are used in a > system catalog that is documented. Right. > Still we have a problem here. I > can actually see a few projects relying on these two functions while > looking a bit around, so they are used. And the issue comes from > ddfc2d9, that has removed these functions from the documentation > ignoring that they are used in no system catalogs. I think that we > should fix that and re-add the two missing functions with a proper > description in the docs, at least? As they could be/are used outside of the xact view, yes I think the same. > There is no trace of them. > Perhaps the ones exposted through pg_stat_xact_all_tables are fine if > not listed. I'd be tempted to add documentation for all of them, I can look at it. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com