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 1lopMG-0000lf-IB for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Jun 2021 15:34:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lopME-0003FQ-H3 for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Jun 2021 15:34:06 +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 1lopME-0003FI-6e for pgsql-hackers@lists.postgresql.org; Thu, 03 Jun 2021 15:34:06 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lopM8-0005BD-0h for pgsql-hackers@lists.postgresql.org; Thu, 03 Jun 2021 15:34:05 +0000 Received: from Andreys-MacBook-Pro.local (unknown [176.59.196.105]) (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 D27A121C81EF; Thu, 3 Jun 2021 18:33:57 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1622734438; bh=LGaPqNbhvA9onIBiQfyoVIeYC47uyII8as5GWMWZqvQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=SWu24XXjRYI4wjQOe3tJWVDUuOGuppAZevptMBBfwp2tbAfK6tiFUDonfz4YdlwVD RCTYjzaD3/zlcDBIOJDbF9yT0w0yL5hxW4jmKAKrwLdWpv8cJMn/OzZfyckzOVrxtR Z5RlevpUT4YwGxmG8DUmvAtoe0xDwAXDBY9UtmR8= 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> <58fa2aa5-07f5-80b5-59a1-fec8a349fee7@postgrespro.ru> From: Andrey Lepikhov Organization: Postgres Professional Message-ID: <520f3426-466c-0aa2-1bae-6188466203db@postgrespro.ru> Date: Thu, 3 Jun 2021 20:33:56 +0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 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 3/6/21 14:49, Etsuro Fujita wrote: > On Tue, May 11, 2021 at 6:55 PM Etsuro Fujita wrote: >> On Tue, May 11, 2021 at 6:27 PM Andrey Lepikhov >> wrote: >>> On 11/5/21 12:24, Etsuro Fujita wrote: >> >>>>> -> 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. ..." >> >> +1 But I think this is an independent issue, so I think it would be >> better to address the issue separately. > > I think that since postgres-fdw.sgml would be for users rather than > developers, unlike fdwhandler.sgml, it would be better to explain this > more in a not-too-technical way. So how about something like this? > > Asynchronous execution is applied even when an Append node contains > subplan(s) executed synchronously as well as subplan(s) executed > asynchronously. In that case, if the asynchronous subplans are ones > executed using postgres_fdw, tuples from the asynchronous subplans are > not returned until after at least one synchronous subplan returns all > tuples, as that subplan is executed while the asynchronous subplans > are waiting for the results of queries sent to foreign servers. This > behavior might change in a future release. Good, this text is clear for me. -- regards, Andrey Lepikhov Postgres Professional