mysql_fdw icon indicating copy to clipboard operation
mysql_fdw copied to clipboard

[Feature Support] Support push down unique function in WHERE clause only: pi(), rand(),..

Open khieuvm opened this issue 2 years ago • 0 comments

Currently, PostgreSQL does not allow pushdown constant functions like (pi(), rand(), ...), so these functions will be calculated in PostgreSQL core and can not be pushed down to the remote database.

But we can push down them to the remote database by creating a stub function:

EXPLAIN VERBOSE
SELECT value1 FROM s3 WHERE mysql_pi() > value1 LIMIT 1;
                                           QUERY PLAN                                            
-------------------------------------------------------------------------------------------------
 Foreign Scan on public.s3  (cost=100.00..100.07 rows=1 width=8)
   Output: value1
   Local server startup cost: 10
   Remote query: SELECT `value1` FROM `mysql_fdw_regress`.`s3` WHERE ((pi() > `value1`)) LIMIT 1
(4 rows)

I would like to contribute them to the repository and community. I will create a pull request to share this feature if you have any interest.

khieuvm avatar Mar 29 '22 10:03 khieuvm