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 1kkNQq-0000pE-Ie for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Dec 2020 08:24:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kkNQp-0004cm-HA for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Dec 2020 08:24:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkNQp-0004cf-Ab for pgsql-hackers@lists.postgresql.org; Wed, 02 Dec 2020 08:24:11 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kkNQn-0007J9-AP for pgsql-hackers@lists.postgresql.org; Wed, 02 Dec 2020 08:24:10 +0000 Received: by mail-pj1-x1031.google.com with SMTP id iq13so591319pjb.3 for ; Wed, 02 Dec 2020 00:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4TsHKMVd36ELEPDUMJa4Sh/Dc0paeR2DQsfqyNl03fM=; b=iF6+DJ9/9nqb3DW5njUeLhAoHOirwVIbc4GPbHAlBmmiADc3TR7g+m+uJvU/oTwRdt c/Vv5o8zJsyCqWTaAtVLxNT+yqB3aRTCL+oPk0IdWyR7KYxVtEnCLNfGyneBE8rzc2cm iAerted3z4TZ377C+tGVcLNwrj4oQJb6yU7EKhkldtViDf7zAbUJMlruIwLJruykuUyC IlM3tfH5hD0mzOEhJHMH/jZb3PzRaXkHcd73lXgM8eaWIDVx6t0+fo/A8E7vOtrVQxPH 53kh/P0l/SUr68cVK5l/7NEW2LvvQO828NQVWW/oXLETGiZ0Wc4XquyEDTRWoZ+zVqgq P50Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4TsHKMVd36ELEPDUMJa4Sh/Dc0paeR2DQsfqyNl03fM=; b=Gv6glVmXV+bbzosxVwdiK4CVV8pNhsrXSBjnqw0EXS4Y5VH8bgOwN4ugh/jJKiyb0h nPoJxq9iEay6TwJddo996nuJLoTzkqlb0EMqr9NDZx2b5WI3EQ5Pz/2tfw5lUKnb2W71 0UKX0/CGspBJ/t+3hWq8rj9dWMQq14ppqCscSzQuOT8KLxXZey0BSnyoKTc7B6eCuvra G2HxPAa2dh1zXKcy2Ur6hXU7YhBZfHOrZPTk/3dxs9t0NhhXHqFgO6MWVfk+PQLYrV+X 5/DMAxUElcwFweAqQbabP9s+UMuTdoHTrOp6t66QDge0ugT+VgVS2MKqho0nYaVIddmQ e9Ig== X-Gm-Message-State: AOAM532ekw4X10MQ4GnYcy8ZA7dohiYCBc9i3KMxFfzUsLLyVxL9VDjJ vmupEVKunkGBaXnRvzCDy0I= X-Google-Smtp-Source: ABdhPJxp5z8KL0K/1jtKTtHlOk9fFh0UrSv3M32kXGU/XNes6D5sns1wKrrnNSzeYic/U3rWI2Ew1Q== X-Received: by 2002:a17:90a:1b41:: with SMTP id q59mr1343692pjq.17.1606897447938; Wed, 02 Dec 2020 00:24:07 -0800 (PST) Received: from nol (36-228-92-107.dynamic-ip.hinet.net. [36.228.92.107]) by smtp.gmail.com with ESMTPSA id p1sm1486023pfb.208.2020.12.02.00.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 00:24:07 -0800 (PST) Date: Wed, 2 Dec 2020 16:24:02 +0800 From: Julien Rouhaud To: Fujii Masao Cc: Nikolay Samokhvalov , PostgreSQL Hackers Subject: Re: pg_stat_statements oddity with track = all Message-ID: <20201202082402.GB51769@nol> References: <20201202040516.GA43757@nol> <20201202063241.GA51769@nol> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Dec 02, 2020 at 03:52:37PM +0900, Fujii Masao wrote: > > On 2020/12/02 15:32, Julien Rouhaud wrote: > > On Tue, Dec 01, 2020 at 10:08:06PM -0800, Nikolay Samokhvalov wrote: > > > On Tue, Dec 1, 2020 at 8:05 PM Julien Rouhaud wrote: > > > > > > > Someone raised an interested point recently on pg_stat_kcache extension for > > > > handling nested statements, which also applies to pg_stat_statements. > > > > > > > ... > > > > > > > The only idea I have for that is to add a new field to entry key, for > > > > instance > > > > is_toplevel. > > [...] > > Just idea; instead of boolean is_toplevel flag, what about > counting the number of times when the statement is executed > in toplevel, and also in nested level? Ah, indeed that would avoid extraneous entries. FTR we would also need that for the planning part. The cons I can see is that it'll make the counters harder to process (unless we provide a specific view for the top-level statements only for instance), and that it assumes that doing a simple division is representative enough for the top level/nested repartition. This might be quite off for in some cases, e.g. big stored procedures due to lack of autovacuum, but that can't be worse than what we currently have.