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 1jH6MF-0005Ls-BW for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2020 13:46:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jH6MC-0002lE-GU for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2020 13:46:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jH6MC-0002l6-56 for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2020 13:46:08 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jH6M3-0001Do-JW for pgsql-hackers@postgresql.org; Wed, 25 Mar 2020 13:46:07 +0000 Received: by mail-wm1-x341.google.com with SMTP id a9so2715565wmj.4 for ; Wed, 25 Mar 2020 06:45:59 -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=iOnMNs6dyfoU0Baa0C/kHWdR9TV5o/6/Pas3F8Zv4YU=; b=sVYypzv+Dzaq/kGOFBP0P4mKBQJIknUylRCCDeNssCxNbqtGSd97yfhgT6S7LuVdBm KR7kRhXgt2tThvuIulHvGG3ye4DcAXrnM2EMe47DKwTA4kT836dCE+fBTyTBUHNv8vQu cDiXAiot0iXIODF2y+oUBSFN7rDQqEY/FN0tVrpUR7IVep4bD73Q/7nsQyPuV3EQ/MeN T/jnjKl+TZRgaiTAIX1htsHgHLokDnPmnpT/q/X0Dd+XEobN5fAgaddyc2rME/qWt8yi bIdoOnbWPBYUhB2nDNZx7bL8JB3oMJV1eThec1TFFpfPJV+fYMM6gw6QOUVCBUseK5Jt fKYw== 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=iOnMNs6dyfoU0Baa0C/kHWdR9TV5o/6/Pas3F8Zv4YU=; b=MfL/hoFw+MFwdfUOP6+P7tViYPwU0QVjRmmN8703yJT6NGaIBdWjxIzyUhemZi7QuW m/ESOg+jTIRNSBW3mh5dAlyWDHOs+yTtdCS2oXXkRgHT7qzkBq/5U5IBUSqZLQ671g6L KBpU6T2aWpAHfu7nuqPACuscD9I1/5jbOL0zCJr9OI8HUMDV4WuT73FNHhUBVPAZws5w nZG6MVLSCNrpgafkI2J3785vViEFJV+yMfy0kTlAJkP37flPk13HC0QvDHcksRZGQN9Z zzg59NTx6jmVn9E/6C98umgCCawKqQTzxBCrtBfkykE6Mmo0hZ0rMLhVO4WaPUZ6/IhL Xs2A== X-Gm-Message-State: ANhLgQ0l8ZbUZYsP5vAUstXuuJXIl/xBsSbKnXGZJhHtdbot+Q6EMOj+ R19rY3JjicNpdIcQlGM0hUU= X-Google-Smtp-Source: ADFU+vvrHYyWt5mvxVCLAah1LzE4ZrEkM1e8uNJQYmSUBDWioP/wHWrVh0RNnNW94R1JjE/+e4/EEA== X-Received: by 2002:a05:600c:20a:: with SMTP id 10mr3676894wmi.135.1585143958319; Wed, 25 Mar 2020 06:45:58 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id v8sm34222342wrw.2.2020.03.25.06.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 06:45:57 -0700 (PDT) Date: Wed, 25 Mar 2020 14:45:53 +0100 From: Julien Rouhaud To: Fujii Masao Cc: Sergei Kornilov , "imai.yoshikazu@fujitsu.com" , legrand legrand , "pgsql-hackers@postgresql.org" Subject: Re: Planning counters in pg_stat_statements (using pgss_store) Message-ID: <20200325134553.GA14054@nol> References: <1584180240397-0.post@n3.nabble.com> <20200314172733.mg7qpyumlyythm25@nol> <20200316214912.iakenhp7vyd37hmg@nol> <6300601584711975@vla4-87a00c2d2b1b.qloud-c.yandex.net> <20200320193004.rqgf3iim4fugq3sm@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, Mar 25, 2020 at 10:09:37PM +0900, Fujii Masao wrote: > > On 2020/03/21 4:30, Julien Rouhaud wrote: > > On Fri, Mar 20, 2020 at 05:09:05PM +0300, Sergei Kornilov wrote: > > > Hello > > > > > > Yet another is missed in docs: total_time > > > > Oh good catch! I rechecked many time the field, and totally missed that the > > documentation is referring to the view, which has an additional column, and not > > the function. Attached v9 fixes that. > > Thanks for the patch! Here are the review comments from me. > > - PGSS_V1_3 > + PGSS_V1_3, > + PGSS_V1_8 > > WAL usage patch [1] increments this version to 1_4 instead of 1_8. > I *guess* that's because previously this version was maintained > independently from pg_stat_statements' version. For example, > pg_stat_statements 1.4 seems to have used PGSS_V1_3. Oh right. It seems that I changed that many versions ago, I'm not sure why. I'm personally fine with any, but I think this was previously raised and consensus was to keep distinct counters. Unless you prefer to keep it this way, I'll send an updated version (with other possible modifications depending on the rest of the mail) using PGSS_V1_4. > + /* > + * We can't process the query if no query_text is provided, as pgss_store > + * needs it. We also ignore query without queryid, as it would be treated > + * as a utility statement, which may not be the case. > + */ > > Could you tell me why the planning stats are not tracked when executing > utility statements? In some utility statements like REFRESH MATERIALIZED VIEW, > the planner would work. I explained that in [1]. The problem is that the underlying statement doesn't get the proper stmt_location and stmt_len, so you eventually end up with two different entries. I suggested fixing transformTopLevelStmt() to handle the various DDL that can contain optimisable statements, but everyone preferred to postpone that for a future enhencement. > +static BufferUsage > +compute_buffer_counters(BufferUsage start, BufferUsage stop) > +{ > + BufferUsage result; > > BufferUsageAccumDiff() has very similar logic. Isn't it better to expose > and use that function rather than creating new similar function? Oh, I thought this wouldn't be acceptable. That's indeed better so I'll do that instead. > values[i++] = Int64GetDatumFast(tmp.rows); > values[i++] = Int64GetDatumFast(tmp.shared_blks_hit); > values[i++] = Int64GetDatumFast(tmp.shared_blks_read); > > Previously (without the patch) pg_stat_statements_1_3() reported > the buffer usage counters updated only in execution phase. But, > in the patched version, pg_stat_statements_1_3() reports the total > of buffer usage counters updated in both planning and execution > phases. Is this OK? I'm not sure how seriously we should ensure > the backward compatibility for pg_stat_statements.... That's indeed a behavior change, although the new behavior is probably better as user want to know how much resource a query is consuming overall. We could distinguish all buffers with a plan/exec version, but it seems quite overkill. > +/* contrib/pg_stat_statements/pg_stat_statements--1.7--1.8.sql */ > > ISTM it's good timing to have also pg_stat_statements--1.8.sql since > the definition of pg_stat_statements() is changed. Thought? I thought that since CreateExtension() was modified to be able to find it's way automatically, we shouldn't provide base version anymore, to minimize maintenance burden and also avoid possible bug/discrepancy. The only drawback is that it'll do multiple CREATE or DROP/CREATE of the function usually once per database, which doesn't seem like a big problem. [1] https://www.postgresql.org/message-id/CAOBaU_Y-y+VOhTZgDOuDk6-9V72-ZXdWccXo_kx0P4DDBEEh9A@mail.gmail.com