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 1lexmy-0003u6-9b for pgsql-hackers@arkaria.postgresql.org; Fri, 07 May 2021 10:32:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lexmv-00048K-OA for pgsql-hackers@arkaria.postgresql.org; Fri, 07 May 2021 10:32:53 +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 1lexmv-00048B-Ed for pgsql-hackers@lists.postgresql.org; Fri, 07 May 2021 10:32:53 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lexms-0005Ld-O5 for pgsql-hackers@lists.postgresql.org; Fri, 07 May 2021 10:32:52 +0000 Received: from ip-192-168-0-192.is74.loc (pool-77-222-104-44.is74.ru [77.222.104.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 9247721C8193; Fri, 7 May 2021 13:32:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1620383568; bh=/f5zP0fnUw1iG4S8uj03eVPAhOR3okXkuavvJVyvrmk=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=GDAog7+m3nHQFYofAfPhVPFWKV/6Q6kO51dBLx7rboB2Qdq1eAe1BQSkhhF8EymkA TYnD4333km61ywjHHSzjfRLROD+Djw0e7gUO605runcCNrYyDQLrCc0oVBZpA95Kxv ZaIapMji6Jg+ZRLXdwe6rK+KFqahYtIP+2cWgXG0= Subject: Re: Asynchronous Append on postgres_fdw nodes. To: Etsuro Fujita Cc: Kyotaro Horiguchi , Justin Pryzby , PostgreSQL Hackers References: <20210331.101137.148208859959175708.horikyota.ntt@gmail.com> <2eb662bb-105d-fc20-7412-2f027cc3ca72@postgrespro.ru> From: Andrey Lepikhov Organization: Postgres Professional Message-ID: Date: Fri, 7 May 2021 15:32:47 +0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------9AAB55F860D87CE044F34A7D" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------9AAB55F860D87CE044F34A7D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 6/5/21 11:45, Etsuro Fujita wrote: > On Tue, Apr 27, 2021 at 9:31 PM Etsuro Fujita wrote: > The patch fixes the issue, but I don’t think it’s the right way to go, > because it requires an extra ExecProcNode() call, which wouldn’t be > efficient. Also, the patch wouldn’t address another issue I noticed > in EXPLAIN ANALYZE for async-capable nodes that the command wouldn’t > measure the time spent in such nodes accurately. For the case of > async-capable node using postgres_fdw, it only measures the time spent > in ExecProcNode() in ExecAsyncRequest()/ExecAsyncNotify(), missing the > time spent in other things such as creating a cursor in > ExecAsyncRequest(). :-(. To address both issues, I’d like to propose > the attached, in which I added instrumentation support to > ExecAsyncRequest()/ExecAsyncConfigureWait()/ExecAsyncNotify(). I > think this would not only address the reported issue more efficiently, > but allow to collect timing for async-capable nodes more accurately. Ok, I agree with the approach, but the next test case failed: EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM ( (SELECT * FROM f1) UNION ALL (SELECT * FROM f2) ) q1 LIMIT 100; ERROR: InstrUpdateTupleCount called on node not yet executed Initialization script see in attachment. -- regards, Andrey Lepikhov Postgres Professional --------------9AAB55F860D87CE044F34A7D Content-Type: application/sql; x-mac-type="0"; x-mac-creator="0"; name="t1.sql" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="t1.sql" RFJPUCBFWFRFTlNJT04gSUYgRVhJU1RTIHBvc3RncmVzX2ZkdyBDQVNDQURFOwpEUk9QIFRB QkxFIElGIEVYSVNUUyBsMSxsMixsMywgcGFydCBDQVNDQURFOwogCkNSRUFURSBFWFRFTlNJ T04gcG9zdGdyZXNfZmR3OwpDUkVBVEUgU0VSVkVSIGxvb3BiYWNrMSBGT1JFSUdOIERBVEEg V1JBUFBFUiBwb3N0Z3Jlc19mZHcgT1BUSU9OUyAoYXN5bmNfY2FwYWJsZSAndHJ1ZScpOwpD UkVBVEUgU0VSVkVSIGxvb3BiYWNrMiBGT1JFSUdOIERBVEEgV1JBUFBFUiBwb3N0Z3Jlc19m ZHcgT1BUSU9OUyAoYXN5bmNfY2FwYWJsZSAndHJ1ZScpOwpDUkVBVEUgU0VSVkVSIGxvb3Bi YWNrMyBGT1JFSUdOIERBVEEgV1JBUFBFUiBwb3N0Z3Jlc19mZHcgT1BUSU9OUyAoYXN5bmNf Y2FwYWJsZSAndHJ1ZScpOwoKQ1JFQVRFIFVTRVIgTUFQUElORyBGT1IgUFVCTElDIFNFUlZF UiBsb29wYmFjazE7CkNSRUFURSBVU0VSIE1BUFBJTkcgRk9SIFBVQkxJQyBTRVJWRVIgbG9v cGJhY2syOwpDUkVBVEUgVVNFUiBNQVBQSU5HIEZPUiBQVUJMSUMgU0VSVkVSIGxvb3BiYWNr MzsKIApDUkVBVEUgVEFCTEUgbDEoYSBpbnQpOwpDUkVBVEUgRk9SRUlHTiBUQUJMRSBmMShh IGludCkgU0VSVkVSIGxvb3BiYWNrMSBPUFRJT05TICh0YWJsZV9uYW1lICdsMScpOwpDUkVB VEUgVEFCTEUgbDIoYSBpbnQpOwpDUkVBVEUgRk9SRUlHTiBUQUJMRSBmMihhIGludCkgU0VS VkVSIGxvb3BiYWNrMiBPUFRJT05TICh0YWJsZV9uYW1lICd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