Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jHTgB-0006HV-W2 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 14:40:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHTgA-0005g0-Rg for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 14:40:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHTgA-0005ft-Cl for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2020 14:40:18 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jHTg8-0003Gs-1j for pgsql-hackers@postgresql.org; Thu, 26 Mar 2020 14:40:17 +0000 Received: by mail-lf1-x141.google.com with SMTP id z23so5041056lfh.8 for ; Thu, 26 Mar 2020 07:40:15 -0700 (PDT) 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=8A0QxyPp2KXZUBfVf6A5ZzUemdYZ2D1QENYzi5v4jrE=; b=dZw0AoJeo7ZFe6+4wxcyavtR/s0+rBFGpoWXXalnjOI+jFS7LY/5woGkvuq0b/gePC gm2SECYKXwFoO1aw3kyQSfz1FuLT8COfgGHzOs9ltObsRM3LPXdct2ZAga7n7EcRvrss P9CZIgWY7gwazywVAKT1hJL4qUvIbho/QnrqOLf59J+K4RJdpqYHPE5rCRbyaVVoy4Q4 r/tawfX/DEUZ8nJS9RWssg14agLfOJ4kiKkuAnJqr1Sgw2XM1PM0XNrRUX/T8jJyazMK xwsAjRafcaTE72xaLjR7oPEgyTkIpFWSf1Dzx7XMhGl4QM7oS28A+vXbVEqs/XxGO5rI b3Dg== 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=8A0QxyPp2KXZUBfVf6A5ZzUemdYZ2D1QENYzi5v4jrE=; b=TNCw550GJt9nEvoIcNML9SR7OjQzZIJFuPPEYFfdcYjP4PpcW8LfnY8MJ/vlDh5obg irFk4IreBRJg4rIrEj58qqYEHzxU3uC24VC+CrwzfdhglpRAyv9pYxMZLwCn+qJUlVgo NzrZo+MLqMncCcFGSv6kbI8lTLbWalVz68+C05jEu1DirP0oLbZxXZdB0osDfLeq/Gye Zy/453+R1ZOlKMTvIMnov+cX/STGnnbgVcjNpmZS3jq7XXoAXMbuA9y8/oLjRGX/XlGE jFxga+jOG9JhBmOkby5RxledRC+pMo8pkL9JdzvnAhIG96SlUFkiBWbCnwB7bJafsbyF bU0Q== X-Gm-Message-State: ANhLgQ29hBjU8/VMb/Q5x4vxNhnjk4gy44PcNBXG2N4I9mv2sX1/uecO AkDmyH/MGqEzsYWlUC/uwcsNhn5+meg= X-Google-Smtp-Source: ADFU+vvJBdxmZcuX1c2YTkLwjMxOoNNYk1ChMAd4k92KqWGokogyM8tPjfHvlDFpLqLYxkg7YaRptQ== X-Received: by 2002:a19:ad43:: with SMTP id s3mr6045894lfd.63.1585233614230; Thu, 26 Mar 2020 07:40:14 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id z13sm1648267lfd.79.2020.03.26.07.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 07:40:13 -0700 (PDT) Date: Thu, 26 Mar 2020 15:40:09 +0100 From: Julien Rouhaud To: Fujii Masao Cc: legrand legrand , pgsql-hackers@postgresql.org Subject: Re: Patch: to pass query string to pg_plan_query() Message-ID: <20200326144009.GC80836@nol> References: <1583789487074-0.post@n3.nabble.com> <6ecbaaca-5a8e-5fe6-f7e1-a893e708bd7b@oss.nttdata.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6ecbaaca-5a8e-5fe6-f7e1-a893e708bd7b@oss.nttdata.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Mar 26, 2020 at 10:54:35PM +0900, Fujii Masao wrote: > > On 2020/03/10 6:31, legrand legrand wrote: > > Hello, > > > > This is a call for committers, reviewers and users, > > regarding "planning counters in pg_stat_statements" > > patch [1] but not only. > > Does anyone object to this patch? I'm thinking to commit it separetely > at first before committing the planning_counter_in_pg_stat_statements > patch. > > > Historically, this version of pg_stat_statements > > with planning counters was performing 3 calls to > > pgss_store() for non utility statements in: > > 1 - pgss_post_parse_analyze (init entry with queryid > > and store query text) > > 2 - pgss_planner_hook (to store planning counters) > > 3 - pgss_ExecutorEnd (to store execution counters) > > > > Then a new version was proposed to remove one call > > to pgss_store() by adding the query string to the > > planner pg_plan_query(): > > But pgss_store() still needs to be called three times even in > non-utility command if the query has constants. Right? Yes indeed, this version is actually adding the 3rd pgss_store call. Passing the query string is a collateral requirement in case the entry disappeared between post parse analysis and planning (which is quite possible with prepared statements at least), as pgss will in this case fallback storing the as-is query string, which is still better that no query text at all. > > 1 - pgss_planner_hook (to store planning counters) > > 2 - pgss_ExecutorEnd (to store execution counters) > > > > Many performances tests where performed concluding > > that there is no impact on this subject. > > Sounds good! > > > Patch "to pass query string to the planner", could be > > committed by itself, and (maybe) used by other extensions. > > > > If this was done, this new version of pgss with planning > > counters could be committed as well, or even later > > (being used as a non core extension starting with pg13). > > > > So please give us your feedback regarding this patch > > "to pass query string to the planner", if you have other > > use cases, or any comment regarding core architecture. > > *As far as I heard*, pg_hint_plan extension uses very tricky way to > extract query string in the planner hook. So this patch would be > very helpful to make pg_hint_plan avoid using such tricky way. +1