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 1j9WTi-0001BY-6u for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2020 16:02:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9WTg-0005xD-O0 for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2020 16:02:32 +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 1j9WTg-0005so-8s for pgsql-hackers@lists.postgresql.org; Wed, 04 Mar 2020 16:02:32 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j9WTd-0004Y3-QL for pgsql-hackers@postgresql.org; Wed, 04 Mar 2020 16:02:31 +0000 Received: by mail-wm1-x341.google.com with SMTP id g134so2701312wme.3 for ; Wed, 04 Mar 2020 08:02:29 -0800 (PST) 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:content-transfer-encoding:in-reply-to; bh=oMBKe3kB+T49UXqMy3GCETmeDFksEbX0cVXNYR5zhyQ=; b=FO8qSsI62Tw91papqGeGFI0Cgge0CrU8s8d8nyH6yD5UIkY4BI3ys/T1cHs9rEhs8w nWsLhi8+254ul7rrJE3UyvrCp1q3IC4Ih26MGBpCUn+JfRZaoZFVCl9R4uoDZ1MiDRx5 dCbBkHs8ljW63+ec+buuSnw5/Z8C+KeNss6+eudAu2vrny8/wa59Ufqv29drx9gx/58g WtkNjZGb4tS4/R8w2NYobZupGPTP3TsiousF8uo511YlXhSEQLPnU7UU0cAHb5YUdJtm +Cx9qqKCZyZcVAyTgt9fIwFh+uM6cCIQNwduC2L5G9PUun5XGVT+sYIdvaTS48MgQuBP l0Lw== 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:content-transfer-encoding :in-reply-to; bh=oMBKe3kB+T49UXqMy3GCETmeDFksEbX0cVXNYR5zhyQ=; b=Dnwmwlhpeo38K/SjpF2eKwPdIyVMiPoWGcAgckg39lYOurOKZZlnw4FeptuEtB0O3V dMzlgcqKTuUXyIolwy7GnzoOP53mmGwMkEzIGzohC1BtWjHnhfwYwOk2RCTLnPX2Q+mP DU6dSh9J2ZXORbssAdxSioNmdo7moYX6QElrwqc77VFk7v5BF5owRhODc29RxpYn72KP TT+po2gkQKpBb98mfrgOZO0GvfE4pllJTcqN2bOdOxCs/kFVquMfpHXm1Ok4xmg6h1nq UGTUjmn1d0o13IcRPvi5OvuAaVtNfeDHzpgESv4KUF6sELQs4NhX4quSyqG1uQNekSb1 wMww== X-Gm-Message-State: ANhLgQ1dIZy5hz/VxpIro9g02AnsjWiaIxjNSipmZ6RM3HRkS+wl+EHY cTtQgzZo7S1UITmV54y1Pzc= X-Google-Smtp-Source: ADFU+vuQtjJ6NV+T6pYqNYRES8K4iwX8a2qKBlOK4IljqWxxoO/CsWSBxohMEZass1VaZEv3fPqicw== X-Received: by 2002:a1c:8041:: with SMTP id b62mr4206799wmd.76.1583337748092; Wed, 04 Mar 2020 08:02:28 -0800 (PST) Received: from nol ([2a01:e0a:c:bcf0:dbc8:f7e9:89ae:5cd7]) by smtp.gmail.com with ESMTPSA id n11sm29673563wrq.40.2020.03.04.08.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 08:02:27 -0800 (PST) Date: Wed, 4 Mar 2020 17:02:25 +0100 From: Julien Rouhaud To: Kirill Bychik Cc: PostgreSQL Hackers , Craig Ringer , Thomas Munro Subject: Re: WAL usage calculation patch Message-ID: <20200304160225.GA26982@nol> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Feb 20, 2020 at 06:56:27PM +0300, Kirill Bychik wrote: > > вт, 18 февр. 2020 г. в 06:23, Thomas Munro : > > > On Mon, Feb 10, 2020 at 8:20 PM Craig Ringer wrote: > > > > On Wed, 5 Feb 2020 at 21:36, Kirill Bychik wrote: > > > > > Patch is separated in two parts: core changes and pg_stat_statements > > > > > additions. Essentially the extension has its schema updated to allow > > > > > two more fields, docs updated to reflect the change. Patch is prepared > > > > > against master branch. > > > > > > > > > > Please provide your comments and/or code findings. > > > > > > > > I like the concept, I'm a big fan of anything that affordably improves > > > > visibility into Pg's I/O and activity. > > > > > > +1 Huge +1 too. > > Thank you for testing the patch and running extension checks. I assume > > the patch applies without problems. > > > > As for the regr test, it apparently requires some rework. I didn't pay > > attention enough to make sure the data I check is actually meaningful > > and isolated enough to be repeatable. > > > > Please consider the extension part of the patch as WIP, I'll resubmit > > the patch once I get a stable and meanngful test up. Thanks for > > finding it! > > > > I have reworked the extension regression test to be more isolated. > Apparently, something merged into master branch shifted my numbers. > > PFA the new patch. Core part didn't change a bit, the extension part > has regression test SQL and expected log changed. I'm quite worried about the stability of those counters for regression tests. Wouldn't a checkpoint happening during the test change them? While at it, did you consider adding a full-page image counter in the WalUsage? That's something I'd really like to have and it doesn't seem hard to integrate. Another point is that this patch won't help to see autovacuum activity. As an example, I did a quick test to store the informations in pgstat, sending the data in the PG_FINALLY part of vacuum(): rjuju=# create table t1(id integer, val text); CREATE TABLE rjuju=# insert into t1 select i, 'val ' || i from generate_series(1, 100000) i; INSERT 0 100000 rjuju=# vacuum t1; VACUUM rjuju=# select datname, vac_wal_records, vac_wal_bytes, autovac_wal_records, autovac_wal_bytes from pg_stat_database where datname = 'rjuju'; datname | vac_wal_records | vac_wal_bytes | autovac_wal_records | autovac_wal_bytes ---------+-----------------+---------------+---------------------+------------------- rjuju | 547 | 65201 | 0 | 0 (1 row) rjuju=# delete from t1 where id % 2 = 0; DELETE 50000 rjuju=# select pg_sleep(60); pg_sleep ---------- (1 row) rjuju=# select datname, vac_wal_records, vac_wal_bytes, autovac_wal_records, autovac_wal_bytes from pg_stat_database where datname = 'rjuju'; datname | vac_wal_records | vac_wal_bytes | autovac_wal_records | autovac_wal_bytes ---------+-----------------+---------------+---------------------+------------------- rjuju | 547 | 65201 | 1631 | 323193 (1 row) That's seems like useful data (especially since I recently had to dig into a problematic WAL consumption issue that was due to some autovacuum activity), but that may seem strange to only account for (auto)vacuum activity, rather than globally, grouping per RmgrId or CommandTag for instance. We could then see the complete WAL usage per-database. What do you think? Some minor points I noticed: - the extension patch doesn't apply anymore, I guess since 70a7732007bc4689 #define PARALLEL_KEY_JIT_INSTRUMENTATION UINT64CONST(0xE000000000000009) +#define PARALLEL_KEY_WAL_USAGE UINT64CONST(0xE000000000000010) Shouldn't it be 0xA rather than 0x10? - it would be better to add a version number to the patches, so we're sure which one we're talking about.