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 1nbEMN-0006B9-El for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Apr 2022 04:30:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbEML-0005M2-Nf for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Apr 2022 04:30:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbEML-0005Lt-Ck for pgsql-hackers@lists.postgresql.org; Mon, 04 Apr 2022 04:30:33 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbEMI-00020z-Nn for pgsql-hackers@postgresql.org; Mon, 04 Apr 2022 04:30:33 +0000 Received: by mail-pj1-x1034.google.com with SMTP id s14-20020a17090a880e00b001caaf6d3dd1so79337pjn.3 for ; Sun, 03 Apr 2022 21:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PeDDqQFRv+GXOjxRzIpqJujeX1wSgAB8JlunqhKdSi8=; b=gR0Ndi743OQ9Y1jmj0wUoJg7ynjLM0e/3nFMI1h5P1rZFn/ztX8pWe/GrA/JQTS2Ga KbsSXW+8HNKZViai0s/0eadvGLvY8+44JvcSPsTM9TleuMNnmP/FnitH7+BqGOjt46vy O1HE0ZRQBtCZSBw8bF7o2d5+QBvetUrLH0YI+Zg+20sYaPPOKVWkSETBPak6q6XUj64t uMORhk4ed4W/PRpUGXXzaMTmPEYzPXJrGbstWo8OFhmYXMuasXSAlOUYjgiAwmt5Zsyt vaie46NNNxYn9TxabPvQnhOaJhI7TddBFadWHLbC7qjJhbNagnsCpBMer7Fgadot+oed JTmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PeDDqQFRv+GXOjxRzIpqJujeX1wSgAB8JlunqhKdSi8=; b=awbCNtuYLT2j74hMG+vRjHdfkaDxMDFwIwU9RNEQ0jwJiq0snBfQ5u56XS4usnwizf 35fb3DuMdjfLkseMqJfSmpH0IDC7pvUJfKSY9cSMkR/vbzGCf4siocpIYspIVTID+s9V upA99TKv34HL//tyztmWCA8krfK6uH6i2HhLOPxkxirI+S9VvDMczZRuBwumykDYZWga D/6gHRgJnAyj2wm+kEsxfRuGrKo32xaBl4a26qhH++wpzYsZNuJCqK+4nCPpgzyEzKdB D0LtaM46rn/3zOJ8mIcKr6J4AJZ260H9J7ZS6WptOMivP2Z499rVTjxdcbRFl6QfryG7 K1WA== X-Gm-Message-State: AOAM531YlO3cOzx6jh5q9wPnQgI/xFHdRw4/k8fA/DXKYmORrMr1bQrA n5EARZggTyTn/nroI4nQATQ= X-Google-Smtp-Source: ABdhPJxi2Oyef9OzahZSlwEHFJvwOkTtIDWcj4DcTXD8YM3aA3hrL+1vD/4A2yF3xF8bO3nEZqXheg== X-Received: by 2002:a17:902:e5c7:b0:156:8b5c:606f with SMTP id u7-20020a170902e5c700b001568b5c606fmr7088299plf.100.1649046628372; Sun, 03 Apr 2022 21:30:28 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-f154-9488-2da1-d7d6-5452.dynamic-ip6.hinet.net. [2001:b011:1005:f154:9488:2da1:d7d6:5452]) by smtp.gmail.com with ESMTPSA id q6-20020a056a00150600b004fb2d266f97sm10527063pfu.115.2022.04.03.21.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 21:30:27 -0700 (PDT) Date: Mon, 4 Apr 2022 12:30:20 +0800 From: Julien Rouhaud To: Masahiko Sawada Cc: gkokolatos@pm.me, Ranier Vilela , PostgreSQL-development , depesz@depesz.com Subject: Re: Showing I/O timings spent reading/writing temp buffers in EXPLAIN Message-ID: References: <2sAuEW1zGE4cTWCRPgzvAshfUAM44kW02tc3i31iLLCujLE-tczA8xOGFhs6c2EiEVM5uSQy_cJyvgAA1EKyxRtqnWM_mrirKwsTJ6Kxaaw=@pm.me> <20220119085236.iuuq4rtzm6qxvzls@jrouhaud> 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: Archived-At: Precedence: bulk Hi, On Tue, Mar 01, 2022 at 11:35:32AM +0900, Masahiko Sawada wrote: > On Wed, Jan 19, 2022 at 5:52 PM Julien Rouhaud wrote: > > > > It seems that the regression tests aren't entirely stable, per cfbot: > > https://cirrus-ci.com/github/postgresql-cfbot/postgresql/commitfest/36/3298. > > > > The failures look like: > > > > diff -U3 /tmp/cirrus-ci-build/src/test/recovery/../regress/expected/explain.out /tmp/cirrus-ci-build/src/test/recovery/tmp_check/results/explain.out > > --- /tmp/cirrus-ci-build/src/test/recovery/../regress/expected/explain.out 2022-01-19 03:50:37.087931908 +0000 > > +++ /tmp/cirrus-ci-build/src/test/recovery/tmp_check/results/explain.out 2022-01-19 03:57:41.013616137 +0000 > > @@ -512,9 +512,10 @@ > > I/O Timings: temp read=N.N write=N.N > > -> Function Scan on generate_series (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N loops=N) > > I/O Timings: temp read=N.N write=N.N > > + I/O Timings: shared/local read=N.N > > Planning Time: N.N ms > > Execution Time: N.N ms > > -(6 rows) > > +(7 rows) > > > > select explain_filter('explain (analyze, buffers, format json) select count(*) from generate_series(1, 100000)'); > > explain_filter > > > > > > I don't see any obvious error in the code, so I'm wondering if it's simply > > the result of populating the cache with generate_series() info. > > Thank you for reporting. > > You're right, the regression test with track_io_timing = on is not > entirely stable because we may read catalog data during planning time, > resulting in an additional line in the EXPLAIN output. I've removed > the regression tests. Hmm, but AFAICS the json format would be stable as the counters are always shown even if zero. So just doing the json format first and then the text format should also work. Although if you're really unlucky there could be a cache invalidation in between so we could just ignore the text format. But I think we should at least keep a regression test with the json format, with a comment explain why only this one is tested. > I've attached updated patches. I've included an improvement of > pg_stat_statement support to support temp I/O timing. Great! Some other considerations: - should we update pg_stat_statements documentation (and comments) for blk_(read|write)_time to mention that it's for *data file* blocks rather than simply blocks? It seems obvious now that we'd have temp_blk_(read|write)_time, but still. This part should probably be backpatched. - not really your patch fault I guess, but I see that extendBufFile() isn't handled. There shouldn't be much activity there so maybe it's ok. This is likely because smgr_extend is also not handled, but this one seems much more likely to take quite some time, and therefore should bump the timing counters.