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 1pSb0d-0001lK-Oa for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 09:56:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSb0c-00072W-7t for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 09:56:58 +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 1pSb0b-00072H-SN for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 09:56:57 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSb0V-00050A-6d for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 09:56:56 +0000 Received: by mail-wm1-x333.google.com with SMTP id g6-20020a05600c310600b003e1f6dff952so3737593wmo.1 for ; Thu, 16 Feb 2023 01:56:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=Vi++xw0WLS9FYac+8lM5DWSGTV5EaEqjYyNgXlooIts=; b=GAvNr3eYhBfalowqiH53aBWUqt1ZuTgXjd1BnH5KnfmHYxjCfiy8Aq/1JTy4+4//Ea xfB6kHMiADUFT0JyioyAo/hZo3UGuSKG+LfrHoa0zuQTRaGixGYcozeNmVfkfXO5TJhZ 6hhGXR1E5+zX/gif/D2KrZJuFpsTGuDDobEM2La2cR0Gtvsyk9+bfIgIVzgqfPqZT0Ix W1bf/21lRBEmpwgH0G1dBnLctLPpRz0y7XBzztLVkfwVZfFhMiA4XQ/vFwlk2Vy6awnw D4cVrc8LxZ4OGxL1N5RpdmzFSVImCXLti0TrxujUN8Q1wsXtXRDnZWqPCv5SrnpT1TyF YjcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Vi++xw0WLS9FYac+8lM5DWSGTV5EaEqjYyNgXlooIts=; b=1r3LCyMeBOPyW/ddyHtvaFWlbZ1PmE4SUh87DaTSV9Dwmhv/jTh2ThVRLZdRSLvWMU 7F5X7n13xVSphOsTa/+l5779GStgOGVQNTCjVKHzZcuJNG4PTntC8NE1TFt4fMNSLzgY 1x/bxQ3K0l1hT/J6G4d9lrdfilrOFHuPDUzskh1OkDlBQ8l4XzReN9agQqsRyxFppmjy EV1esgp5JmMYNI7ncpT459Hr8fHdzgurjTWSlPJ/f1h8R8idQmE2X24Y9TvwKOAN2QKh kAH7y4mHean4oUNUheoKLDnPLzS2VyyEeaB9GRVlRzRsfwwPupIBH1shoLg2I9judrA4 J9NA== X-Gm-Message-State: AO0yUKUILtuoEt4io6S0rX/VhlfF23SERWfCObE+swFNabTO8/sQMcqs oy9RHciEyM7CCU3RX98LVuOwNIJenRREzg== X-Google-Smtp-Source: AK7set9wg5l7QMteIPBf8oKHrZDVrpAQF2c6Z8U6uebnLeq49eiFat0EbssGtB9KstWKb41RLRPRHg== X-Received: by 2002:a05:600c:3094:b0:3dd:97d6:8f2e with SMTP id g20-20020a05600c309400b003dd97d68f2emr4306620wmn.17.1676541409719; Thu, 16 Feb 2023 01:56:49 -0800 (PST) Received: from [192.168.22.244] ([54.239.6.188]) by smtp.gmail.com with ESMTPSA id p7-20020a7bcc87000000b003e11f280b8bsm4709494wma.44.2023.02.16.01.56.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Feb 2023 01:56:49 -0800 (PST) Message-ID: <0e067034-e92c-302b-24ed-492bca228e26@gmail.com> Date: Thu, 16 Feb 2023 10:55:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: Normalization of utility queries in pg_stat_statements To: Michael Paquier , Postgres hackers References: Content-Language: en-US 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 Hi, On 2/16/23 1:34 AM, Michael Paquier wrote: > While wondering about this stuff about the last few days and > discussing with bertrand, I have changed my mind on the point that > there is no need to be that aggressive yet with the normalization of > the A_Const nodes, because the query string normalization of > pg_stat_statements is not prepared yet to handle cases where a A_Const > value uses a non-quoted value with whitespaces. The two cases where I > saw an impact is on the commands that can define an isolation level: > SET TRANSACTION and BEGIN. > > For example, applying normalization to A_Const nodes does the > following as of HEAD: > 1) BEGIN TRANSACTION READ ONLY, READ WRITE, DEFERRABLE, NOT DEFERRABLE; > BEGIN TRANSACTION $1 ONLY, $2 WRITE, $3, $4 DEFERRABLE > 2) SET TRANSACTION ISOLATION LEVEL READ COMMITTED; > SET TRANSACTION ISOLATION LEVEL $1 COMMITTED > > On top of that, specifying a different isolation level may cause these > commands to be grouped, which is not really cool. All that could be > done incrementally later on, in 17~ or later depending on the > adjustments that make sense. > Thanks for those patches! Yeah, agree about the proposed approach. > 0002 has been > completed with a couple of commands to track all the commands with > A_Const, so as we never lose sight of what happens. 0004 is what I > think could be done for PG16, where normalization affects only Const. > At the end of the day, this reflects the following commands that use > Const nodes because they use directly queries, so the same rules as > SELECT and DMLs apply to them: > - DECLARE > - EXPLAIN > - CREATE MATERIALIZED VIEW > - CTAS, SELECT INTO > 0001: I like the idea of splitting the existing tests in dedicated files. What do you think about removing: " SET pg_stat_statements.track_utility = FALSE; SET pg_stat_statements.track_planning = TRUE; " In the new pg_stat_statements.sql? That way pg_stat_statements.sql would always behave with default values for those (currently we are setting both of them as non default). Then, with the default values in place, if we feel that some tests are missing we could add them in utility.sql or planning.sql accordingly. 0002: Produces: v2-0002-Add-more-test-for-utility-queries-in-pg_stat_stat.patch:834: trailing whitespace. CREATE VIEW view_stats_1 AS v2-0002-Add-more-test-for-utility-queries-in-pg_stat_stat.patch:838: trailing whitespace. CREATE VIEW view_stats_1 AS warning: 2 lines add whitespace errors. +-- SET TRANSACTION ISOLATION +BEGIN; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; What about adding things like "SET SESSION CHARACTERISTICS AS TRANSACTION..." too? 0003 and 0004: Thanks for keeping 0003 that's useful to see the impact of A_Const normalization. Looking at the diff they produce, I also do think that 0004 is what could be done for PG16. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com