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 1ob2GF-0001HH-8f for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Sep 2022 16:07:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ob2GE-0006Sb-3A for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Sep 2022 16:07:42 +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 1ob2GD-0006SR-Q3 for pgsql-hackers@lists.postgresql.org; Wed, 21 Sep 2022 16:07:41 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ob2GA-0003d0-9Y for pgsql-hackers@lists.postgresql.org; Wed, 21 Sep 2022 16:07:40 +0000 Received: from [192.168.11.3] (p2124250-ipbf2604funabasi.chiba.ocn.ne.jp [123.216.87.250]) by oss.nttdata.com (Postfix) with ESMTPSA id 49ECE60506; Thu, 22 Sep 2022 01:07:34 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.7 at oss.nttdata.com Message-ID: <9b2133f6-7bf6-07c4-e896-7a8d9a629d56@oss.nttdata.com> Date: Thu, 22 Sep 2022 01:07:33 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: Query Jumbling for CALL and SET utility statements Content-Language: en-US To: "Drouvot, Bertrand" , Julien Rouhaud Cc: Michael Paquier , Jeremy Schneider , PostgreSQL Hackers , Pavel Stehule , Andres Freund , "Imseih (AWS), Sami" References: <46ca04f9-1e37-c862-9a28-c5dffaee412f@amazon.com> <20220831190604.l2luuhj3xkau7dvk@awork3.anarazel.de> <09c04aba-7f12-e524-20f7-3f92c1479fdf@amazon.com> <9aee54f2-5cc1-5b64-1f73-6961932e7bd2@amazon.com> <20220908065012.l3bd2np7wj52cxco@jrouhaud> <20220908112919.2ytxpkitiw6lt2u6@jrouhaud> <37d32e91-4a08-afaf-a3a8-fd0578e4db50@oss.nttdata.com> <706ee610-4297-453b-f6f2-1e79161414f6@gmail.com> <6d0d8a57-0e9c-7fcb-5072-aae544dafa5c@gmail.com> From: Fujii Masao In-Reply-To: <6d0d8a57-0e9c-7fcb-5072-aae544dafa5c@gmail.com> 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 2022/09/19 15:29, Drouvot, Bertrand wrote: > Please find attached v6 taking care of the remarks mentioned above. Thanks for updating the patch! +SET pg_stat_statements.track_utility = TRUE; + +-- PL/pgSQL procedure and pg_stat_statements.track = all +-- we drop and recreate the procedures to avoid any caching funnies +SET pg_stat_statements.track_utility = FALSE; Could you tell me why track_utility is enabled just before it's disabled? Could you tell me what actually happens if we don't drop and recreate the procedures? I'd like to know what "any caching funnies" are. +SELECT pg_stat_statements_reset(); +CALL MINUS_TWO(3); +CALL MINUS_TWO(7); +CALL SUM_TWO(3, 8); +CALL SUM_TWO(7, 5); + +SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C"; This test set for the procedures is executed with the following four conditions, respectively. Do we really need all of these tests? track = top, track_utility = true track = top, track_utility = false track = all, track_utility = true track = all, track_utility = false +begin; +prepare transaction 'tx1'; +insert into test_tx values (1); +commit prepared 'tx1'; The test set of 2PC commands is also executed with track_utility = on and off, respectively. But why do we need to run that test when track_utility = off? - if (query->utilityStmt) + if (query->utilityStmt && !jstate) { if (pgss_track_utility && !PGSS_HANDLED_UTILITY(query->utilityStmt)) "pgss_track_utility" should be "pgss_track_utility || FORCE_TRACK_UTILITY(parsetree)" theoretically? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION