On Tue, Jun 20, 2023 at 09:59:11AM +0300, Alexander Pyhalov wrote: > > Therefore, it seems like it would be near-zero cost to just call conn = > > GetConnection() and then PQserverVersion(conn), and ReleaseConnection(). > > You can then use the return value of PQserverVersion() to determine if > > you can push down partial aggregates. > > Hi. > Currently we don't get remote connection while planning if > use_remote_estimate is not set. > Such change would require to get remote connection in planner, not in > executor. > This can lead to change of behavior (like errors in explain when user > mapping is wrong - e.g. bad password is specified). > Also this potentially can lead to establishing connections even when plan > node is not actually used > (like extreme example - select sum(score) from t limit 0). > I'm not saying we shouldn't do it - just hint at possible consequences.
Agreed. I noticed it was doing FDW connections during optimization, but didn't see the postgres_fdw option that would turn it off. Interestingly, it is disabled by default. After considering the options, I think we should have a postgres_fdw option called "planner_version_check", and default that false. When false, a remote server version check will not be performed during planning and partial aggregates will be always be considered. When true, a version check will be performed during planning and partial aggregate pushdown disabled for pre-PG 17 foreign servers during the query. If we want to be more specific, we can call it "check_partial_aggregate_support". -- Bruce Momjian <br...@momjian.us> https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.