Situation:
- I table a table (foreign_table) in a postgres database (db1)
- I create a foreign date wrapper to foreign_table in a different postgres database (db2) using postgres_fdw
- I then perform a "select count(*) from foreign_table" from db2
- This query returns the entire contents of foreign_table to db1 in batches of 100 rows (set by fetch_size).
Issue:
- This causes the query to be incredibly slow as the foreign_table has ~100 million rows.
My question:
Is it possible to "push down" this aggregate function so that the count(*) is performed on the remote postgres database?