Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAeqt-00H399-8W for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Nov 2024 00:33:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tAeqp-001d8g-Qd for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Nov 2024 00:33:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAeqo-001d8W-V7 for pgsql-hackers@lists.postgresql.org; Tue, 12 Nov 2024 00:33:48 +0000 Received: from m16.mail.163.com ([117.135.210.2]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tAeqj-001OhR-Dj for pgsql-hackers@postgresql.org; Tue, 12 Nov 2024 00:33:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=HuDMXAkwrE0iSIq0SeSoUKtOfQGsjn7CNeoIL7/J1UQ=; b=j+bLLflhv2YLku/ICTett0YcrZ2oJAttXL7e44UaiHX1/ANNOze+i++AZukKrA 10lDqDVBy1OmI3rol6GpIL3DNtk1CWE4C5I86EDrG3Ly9gnr+YDNvzLPw+8k6+pl /LOwVmBZxXUqL/U4z11KWStCLRdIvAX+BjijYBW0p5jKY= Received: from lovely-coding (unknown [101.227.46.166]) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wCndwhdojJnnrA8AQ--.28891S3; Tue, 12 Nov 2024 08:33:33 +0800 (CST) From: Andy Fan To: dinesh salve Cc: pgsql-hackers@postgresql.org Subject: Re: explain plans for foreign servers In-Reply-To: (dinesh salve's message of "Mon, 11 Nov 2024 21:12:20 +0530") References: Date: Tue, 12 Nov 2024 08:33:33 +0800 Message-ID: <87pln15m02.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain X-CM-TRANSID: _____wCndwhdojJnnrA8AQ--.28891S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7uF1UXF4ftr13Xr45WFy5XFb_yoW8Ww1kpF Z0q34Y9w1UJF4rZFZ5Zr4xA3Z3WFySyF43JwnrX3s7XFZxJryIvF4vyay5ua9rJrWxuFWa 9F4xXr1fAa1jkaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRrR6xUUUUU= X-Originating-IP: [101.227.46.166] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/1tbiNgiVU2cyll6wjgAAsb List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk dinesh salve writes: Hi, > > I am working on a feature in postgres_fdw extension to show plans used > by remote postgresql servers in the output of the EXPLAIN command. > > I think this will help end users understand query execution plans used > by remote servers. Sample output for table people where people_1 is > local partition and people_2 is remote partition would look like This looks nice! Especially for the people who want a FDW based sharding cluster. > I would like community inputs on below high level thoughts: > > 1. To enable this feature, either we can introduce a new option in > EXPLAIN command e.g. (fetch_remote_plans true) or control this > behaviour using a guc defined in postgres_fdw extension. I am more > inclined towards guc as this feature is for extension > postgres_fdw. Adding the EXPLAIN command option might force other FDW > extensions to handle this. +1. > 2. For ANALYZE = false, the idea is that postgres_fdw would create a > connection to a remote server, prepare SQL to send over connection and > store received plans in ExplainState. > 3. For ANALYZE = true, idea is that postgres_fdw would set a new guc > over connection to remote server, remote server postgres_fdw would > read this guc and send back used query plan as a NOTICE (similar to > auto_explain extension does) with custom header which postgres_fdw > extension understands. We also have an opportunity to introduce a new > message type in the protocol to send back explain plans but it might > look like too much work for this feature. Open to ideas here. This generally looks good to me. Looking forward a patch for the details. -- Best Regards Andy Fan