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 1lauJ9-0005G1-IQ for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Apr 2021 06:01:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lauJ5-0007xO-RF for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Apr 2021 06:01: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 1lauJ5-0007si-GC for pgsql-hackers@lists.postgresql.org; Mon, 26 Apr 2021 06:01:19 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lauJ2-0005fx-FS for pgsql-hackers@lists.postgresql.org; Mon, 26 Apr 2021 06:01:18 +0000 Received: from [192.168.129.197] (unknown [94.25.177.124]) (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 8C09221C60E4; Mon, 26 Apr 2021 09:01:13 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1619416873; bh=LGiq4Qkxsccy/zh/br47cWSFZJQ9gnpXtusIr389YuM=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=bvOhNgNPHBzBY0WYGsuJB983MpMCMxVdY6pkWmsWMckSl6O93qBkVb0/WtBFE3oEB 5zJMl+N3PCo0cufX+H6tTCIPEKoKtwsGQjahd0wnG7YWAFUdVlfHY8g7yIOKs+t3+J zzlHAF6Tu0ep4iKGD+K6oynJ9bnolFmMQHbbJ8K8= Subject: Re: Asynchronous Append on postgres_fdw nodes. To: Etsuro Fujita , Kyotaro Horiguchi Cc: Justin Pryzby , PostgreSQL Hackers References: <20210331.101137.148208859959175708.horikyota.ntt@gmail.com> From: "Andrey V. Lepikhov" Organization: Postgres Professional Message-ID: <30f3bf64-7a40-5d19-5b20-94c4365cbc65@postgrespro.ru> Date: Mon, 26 Apr 2021 11:01:12 +0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.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 4/23/21 8:12 AM, Etsuro Fujita wrote: > I have committed the patch. While studying the capabilities of AsyncAppend, I noticed an inconsistency with the cost model of the optimizer: async_capable = off: -------------------- Append (cost=100.00..695.00 ...) -> Foreign Scan on f1 part_1 (cost=100.00..213.31 ...) -> Foreign Scan on f2 part_2 (cost=100.00..216.07 ...) -> Foreign Scan on f3 part_3 (cost=100.00..215.62 ...) async_capable = on: ------------------- Append (cost=100.00..695.00 ...) -> Async Foreign Scan on f1 part_1 (cost=100.00..213.31 ...) -> Async Foreign Scan on f2 part_2 (cost=100.00..216.07 ...) -> Async Foreign Scan on f3 part_3 (cost=100.00..215.62 ...) Here I see two problems: 1. Cost of an AsyncAppend is the same as cost of an Append. But execution time of the AsyncAppend for three remote partitions has more than halved. 2. Cost of an AsyncAppend looks as a sum of the child ForeignScan costs. I haven't ideas why it may be a problem right now. But I can imagine that it may be a problem in future if we have alternative paths: complex pushdown in synchronous mode (a few rows to return) or simple asynchronous append with a large set of rows to return. -- regards, Andrey Lepikhov Postgres Professional