tds_fdw icon indicating copy to clipboard operation
tds_fdw copied to clipboard

WHERE-clause / column push-down

Open oberstet opened this issue 9 years ago • 10 comments

Would be nice to have the README mention if "where clause push-down" and "column push-down" is supported.

  • https://github.com/EnterpriseDB/mysql_fdw#where-clause-push-down
  • https://github.com/EnterpriseDB/mysql_fdw#column-push-down

I am accessing a partitioned table on MS SQL Server 2008, and the WHERE clause I provide on the PostgreSQL side would allow SQL Server to limit access to 1 partition. However, that doesn't appear to work (it seems the whole table, with all partitions is accessed).

I am working around this by creating the foreign table on a query instead which contains the respective WHERE clause, but this is extremely tedious, since now I need to create a foreign table for each partition of the source table.

oberstet avatar Apr 08 '15 13:04 oberstet

Thanks for linking to mysql_fdw's documentation as an example. I didn't realize that they added where clause push-down and column push-down in a recent release. If I ever decided to add those features to tds_fdw, that would probably be a good implementation to use as a guide.

Unfortunately, I don't have much time to spend on tds_fdw these days. However, if you or anyone else decides to add functionality on their own, I'd love to receive pull requests for the changes.

GeoffMontee avatar Apr 09 '15 15:04 GeoffMontee

@GeoffMontee > Unfortunately, I don't have much time to spend on tds_fdw these days.

Would you be able to add this feature (and writable FDW) under a service contract (paid work going open-source)?

oberstet avatar Apr 09 '15 16:04 oberstet

@oberstet If you don't mind, let's discuss that option via email. Could you please send me an email to [email protected] about this?

GeoffMontee avatar Apr 09 '15 17:04 GeoffMontee

Curious what the status is on WHERE clause push downs. I am unable to use this FDW with Sybase due to having tables with > 3 million rows. I will need the ability to have the remote database filter out the records instead of the local Postgres database.

rpack78 avatar Oct 29 '15 19:10 rpack78

The status is that I hope to implement it some day, but I will need to find the time to do so. I'd say that it's the #1 priority now that memory usage has been improved in recent releases.

If anyone else wants to try implementing it, pull requests are welcome too.

GeoffMontee avatar Oct 29 '15 19:10 GeoffMontee

I just merged WHERE and column pushdown into master in this commit: https://github.com/GeoffMontee/tds_fdw/commit/d1e8f109e814cc6f982e9ff27fcbe2d967540b19

It is based on a port of deparse.c from postgres_fdw to tds_fdw. It only compiles on PostgreSQL 9.5 at the moment, but feel free to test it out, if you'd like.

GeoffMontee avatar Apr 03 '16 20:04 GeoffMontee

The latest commit has this feature working all the way back to 9.2: https://github.com/tds-fdw/tds_fdw/commit/da3c823fdbbe697331cd213bd1cd40f8864c72c4

If anyone tests it out and has any problems, please let me know.

GeoffMontee avatar Apr 16 '16 19:04 GeoffMontee

@GeoffMontee awesome! good job. thanks

oberstet avatar Apr 17 '16 10:04 oberstet

Very kewl. IMHO, WHERE clause push-down is key feature that makes an FDW suitable for many more production use cases. We look forward to including version 2 of TDS_FDW in the http://bigsql.org Distribution of Postgres, as it goes GA.

luss avatar Apr 21 '16 07:04 luss

It seems to work here in version 2.

frafra avatar Jul 09 '19 08:07 frafra