While reviewing [1] it occurred to me that it might not be clean that postgresGetForeignUpperPaths() adds ORDER BY to the remote query when it receives stage=UPPERREL_GROUP_AGG. Shouldn't that only happen for UPPERREL_ORDERED? Thus the processing of UPPERREL_ORDERED would have to be able to handle grouping too, so some refactoring would be needed. Do I misunderstand anything?
[1] https://commitfest.postgresql.org/22/1950/ -- Antonin Houska Cybertec Schönig & Schönig GmbH Gröhrmühlgasse 26, A-2700 Wiener Neustadt Web: https://www.cybertec-postgresql.com