On Wed, Nov 22, 2023 at 1:32 AM Alexander Pyhalov <a.pyha...@postgrespro.ru> wrote: > Hi. HAVING is also a problem. Consider the following query > > SELECT count(a) FROM t HAVING count(a) > 10 - we can't push it down to > foreign server as HAVING needs full aggregate result, but foreign server > don't know it.
I don't see it that way. What we would push to the foreign server would be something like SELECT count(a) FROM t. Then, after we get the results back and combine the various partial counts locally, we would locally evaluate the HAVING clause afterward. That is, partial aggregation is a barrier to pushing down HAVING clause itself, but it doesn't preclude pushing down the aggregation. -- Robert Haas EDB: http://www.enterprisedb.com