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 1lgOfi-0004Q3-2Z for pgsql-hackers@arkaria.postgresql.org; Tue, 11 May 2021 09:27:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOff-0005MF-Sy for pgsql-hackers@arkaria.postgresql.org; Tue, 11 May 2021 09:27:19 +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 1lgOff-0005M5-Hq for pgsql-hackers@lists.postgresql.org; Tue, 11 May 2021 09:27:19 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOfa-0000PJ-0W for pgsql-hackers@lists.postgresql.org; Tue, 11 May 2021 09:27:18 +0000 Received: from [192.168.129.222] (unknown [94.25.177.130]) (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 EF9CB21C7ECB; Tue, 11 May 2021 12:27:10 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1620725231; bh=Lo3jOJobQCXPYn+ktR4HLkgWJxTmePLO9Gxpm5xukE8=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=pcJykKCKcgQq0GEvwzfnX4v+BM748pfVzDr1d/jRz03V9LvKzT1ONTtZ4gNH5uaJJ egsy9X1joDBNEFk2RxnzqEhsGwrI12EbrQ0q5vNelPgmWYsF4nQPg/x8br+eh50DiI frSsZ3rIqQ5EaiK0KPuHoH/xwjBhP7AsFv+KlxKU= 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> <2080193d-da8d-4132-f48c-8e29be8fcffc@postgrespro.ru> From: Andrey Lepikhov Organization: Postgres Professional Message-ID: <58fa2aa5-07f5-80b5-59a1-fec8a349fee7@postgrespro.ru> Date: Tue, 11 May 2021 14:27:10 +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: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/5/21 12:24, Etsuro Fujita wrote: > On Tue, May 11, 2021 at 11:58 AM Andrey Lepikhov > The extra tuple, which is from f1 or f2, would have been kept in the > Append node's as_asyncresults, not returned from the Append node to > the Limit node. The async Foreign Scan nodes would fetch tuples > before the Append node ask the tuples, so the fetched tuples may or > may not be used. Ok.>> -> Append (actual rows=3000 loops=1) >> -> Async Foreign Scan on f1 (actual rows=0 loops=1) >> -> Async Foreign Scan on f2 (actual rows=0 loops=1) >> -> Foreign Scan on f3 (actual rows=3000 loops=1) >> >> Here we give preference to the synchronous scan. Why? > > This would be expected behavior, and the reason is avoid performance > degradation; you might think it would be better to execute the async > Foreign Scan nodes more aggressively, but it would require > waiting/polling for file descriptor events many times, which is > expensive and might cause performance degradation. I think there is > room for improvement, though. Yes, I agree with you. Maybe you can add note in documentation on async_capable, for example: "... Synchronous and asynchronous scanning strategies can be mixed by optimizer in one scan plan of a partitioned table or an 'UNION ALL' command. For performance reasons, synchronous scans executes before the first of async scan. ..." -- regards, Andrey Lepikhov Postgres Professional