atris / JDBC_FDW

FDW that wraps JDBC for PostgreSQL.It can be used to connect and fetch data from any data source that supports JDBC
Other
66 stars 38 forks source link

JDBC_FDW performance issues #35

Open gferrette opened 5 years ago

gferrette commented 5 years ago

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!

kostiantyn-nemchenko commented 5 years ago

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');
atris commented 3 years ago

Patches are welcome