JDBC_FDW icon indicating copy to clipboard operation
JDBC_FDW copied to clipboard

JDBC_FDW performance issues

Open gferrette opened this issue 6 years ago • 2 comments

Hello!

We are using jdbc_fdw to connect do DB2, and we noticed that all queries are very slow compared with the db2 client installed at the same machine. We are firing a query like "select count(*) from table" and with jdbc_fdw it's taking 2 seconds more than db2 client.

Is there any parameter of jdbc_fdw to speed up the queries?

Thanks!

gferrette avatar Jan 18 '19 18:01 gferrette

This extension does not support aggregate push-down, therefore Postgres fetches all the rows from the remote server and then counts them locally.

Currently, the only thing you can do to make things faster is to create a foreign table with query option.

CREATE FOREIGN TABLE table_count(result integer) 
    SERVER db2
    OPTIONS(query 'select count(*) FROM table');

kostiantyn-nemchenko avatar Jan 18 '19 19:01 kostiantyn-nemchenko

Patches are welcome

atris avatar Sep 08 '20 09:09 atris