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 1l2Atb-0007Qp-KE for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jan 2021 10:39:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2AtZ-0007zS-6u for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jan 2021 10:39:25 +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 1l2AtY-0007xu-Vz for pgsql-hackers@lists.postgresql.org; Wed, 20 Jan 2021 10:39:24 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2AtX-0008AP-DS for pgsql-hackers@postgresql.org; Wed, 20 Jan 2021 10:39:24 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTP id C2603601A7; Wed, 20 Jan 2021 19:39:18 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 20 Jan 2021 19:39:18 +0900 From: Masahiro Ikeda To: Julien Rouhaud Cc: Sergei Kornilov , legrand legrand , pgsql-hackers Subject: Re: pg_stat_statements oddity with track = all In-Reply-To: References: <20201202063241.GA51769@nol> <20201203010051.GA8050@nol> <1606983372910-0.post@n3.nabble.com> <1110111606984390@mail.yandex.ru> <20201203085359.GC8050@nol> <20201204081548.GA76762@nol> <109201607072216@mail.yandex.ru> <20201204100913.GB76762@nol> <20201227083857.GA97249@nol> <4dce029c72fc5eb084c5353f31daa13f@oss.nttdata.com> Message-ID: <1ee636ea9e0a579b6bd6fdffa205aaa6@oss.nttdata.com> X-Sender: ikedamsh@oss.nttdata.com User-Agent: Roundcube Webmail/1.1.9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2021-01-20 18:14, Julien Rouhaud wrote: > On Tue, Jan 19, 2021 at 4:55 PM Masahiro Ikeda > wrote: >> I tested the "update" command can work. >> postgres=# ALTER EXTENSION pg_stat_statements UPDATE TO '1.10'; >> >> Although the "toplevel" column of all queries which already stored is >> 'false', >> we have to decide the default. I think 'false' is ok. > > Mmm, I'm not sure that I understand this result. The "toplevel" value > is tracked by the C code loaded at startup, so it should have a > correct value even if you used to have the extension in a previous > version, it's just that you can't access the toplevel field before > doing the ALTER EXTENSION pg_stat_statements UPDATE. There's also a > change in the magic number, so you can't use the stored stat file from > a version before this patch. > > I also fail to reproduce this behavior. I did the following: > > - start postgres with pg_stat_statements v1.10 (so with this patch) in > shared_preload_libraries > - CREATE EXTENSION pg_stat_statements VERSION '1.9'; > - execute a few queries > - ALTER EXTENSION pg_stat_statements UPDATE; > - SELECT * FROM pg_stat_statements reports the query with toplvel to > TRUE > > Can you share a way to reproduce your findings? Sorry for making you confused. I can't reproduce although I tried now. I think my procedure was something wrong. So, please ignore this comment, sorry about that. >> B. check logic whether a query is top-level or not in pg_stat_kcache >> >> This patch uses the only exec_nested_level to check whether a query is >> top-level or not. >> The reason is nested_level is less useful and I agree. > > Do you mean plan_nest_level is less useful? I think so. Anyway, it's important to correspond core's implementation because pg_stat_statements and pg_stat_kcache are used at the same time. Regards, -- Masahiro Ikeda NTT DATA CORPORATION